Commit 130eedc4 by Hugo Häggmark

Found another input that was tied to a regexp

parent 5388541f
import React, { ChangeEvent, forwardRef } from 'react';
import React, { forwardRef } from 'react';
const specialChars = ['(', '[', '{', '}', ']', ')', '|', '*', '+', '-', '.', '?', '<', '>', '#', '&', '^', '$'];
export const escapeStringForRegex = (event: ChangeEvent<HTMLInputElement>) => {
const value = event.target.value;
export const escapeStringForRegex = (value: string) => {
if (!value) {
return value;
}
......@@ -42,7 +41,7 @@ export const RegExpSafeInput = forwardRef<HTMLInputElement, Props>((props, ref)
type="text"
className={props.className}
value={unEscapeStringFromRegex(props.value)}
onChange={event => props.onChange(escapeStringForRegex(event))}
onChange={event => props.onChange(escapeStringForRegex(event.target.value))}
placeholder={props.placeholder ? props.placeholder : null}
/>
));
......@@ -5,6 +5,7 @@ import AsyncSelect from '@torkelo/react-select/lib/Async';
import { TagOption } from './TagOption';
import { TagBadge } from './TagBadge';
import { components } from '@torkelo/react-select';
import { escapeStringForRegex } from '../RegExpSafeInput/RegExpSafeInput';
export interface Props {
tags: string[];
......@@ -51,7 +52,7 @@ export class TagFilter extends React.Component<Props, any> {
value: tags,
styles: resetSelectStyles(),
filterOption: (option, searchQuery) => {
const regex = RegExp(searchQuery, 'i');
const regex = RegExp(escapeStringForRegex(searchQuery), 'i');
return regex.test(option.value);
},
components: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment