Only pop emoji autocomplete for strict set of characters
This commit is contained in:
parent
b19659f5ac
commit
0beb1416d1
1 changed files with 2 additions and 1 deletions
|
@ -30,6 +30,7 @@ import {
|
||||||
import { LocalizerType } from '../types/Util';
|
import { LocalizerType } from '../types/Util';
|
||||||
|
|
||||||
const colonsRegex = /(?:^|\s):[a-z0-9-_+]+:?/gi;
|
const colonsRegex = /(?:^|\s):[a-z0-9-_+]+:?/gi;
|
||||||
|
const triggerEmojiRegex = /^(?:[-+]\d|[a-z]{2})/i;
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
readonly i18n: LocalizerType;
|
readonly i18n: LocalizerType;
|
||||||
|
@ -276,7 +277,7 @@ export const CompositionInput = ({
|
||||||
} else {
|
} else {
|
||||||
resetEmojiResults();
|
resetEmojiResults();
|
||||||
}
|
}
|
||||||
} else if (newSearchText.length >= 2 && focusRef.current) {
|
} else if (triggerEmojiRegex.test(newSearchText) && focusRef.current) {
|
||||||
setEmojiResults(search(newSearchText, 10));
|
setEmojiResults(search(newSearchText, 10));
|
||||||
setSearchText(newSearchText);
|
setSearchText(newSearchText);
|
||||||
setEmojiResultsIndex(0);
|
setEmojiResultsIndex(0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue