Found another input that was tied to a regexp
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
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: {
|
||||
|
||||
Reference in New Issue
Block a user