Skip to content

Commit 666c98a

Browse files
authored
Merge pull request #823 from GetStream/fix-emoji-regex
CRS-474 Fix trigger autocomplete error
2 parents 80e3216 + 4e87479 commit 666c98a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/components/AutoCompleteTextarea/List.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useCallback, useContext, useEffect, useState } from 'react';
22

33
import { TranslationContext } from '../../context/TranslationContext';
4+
import { escapeRegExp } from '../../utils';
45

56
import Item from './Item';
67
import { KEY_CODES } from './listener';
@@ -125,7 +126,7 @@ const List = (props) => {
125126
const restructureItem = (item) => {
126127
const matched = item.name || item.id;
127128

128-
const editedPropValue = propValue.slice(1);
129+
const editedPropValue = escapeRegExp(propValue.slice(1));
129130
const parts = matched.split(new RegExp(`(${editedPropValue})`, 'gi'));
130131

131132
const itemNameParts = { match: editedPropValue, parts };

src/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export const renderText = <Us extends DefaultUserType<Us> = DefaultUserType>(
233233
);
234234
};
235235

236-
function escapeRegExp(text: string) {
236+
export function escapeRegExp(text: string) {
237237
return text.replace(/[-[\]{}()*+?.,\\^$|#]/g, '\\$&');
238238
}
239239

0 commit comments

Comments
 (0)