Skip to content

Commit

Permalink
Only pop emoji autocomplete for strict set of characters
Browse files Browse the repository at this point in the history
  • Loading branch information
kenpowers-signal authored and scottnonnenberg-signal committed Aug 22, 2019
1 parent b19659f commit 0beb141
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ts/components/CompositionInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import { LocalizerType } from '../types/Util';

const colonsRegex = /(?:^|\s):[a-z0-9-_+]+:?/gi;
const triggerEmojiRegex = /^(?:[-+]\d|[a-z]{2})/i;

export type Props = {
readonly i18n: LocalizerType;
Expand Down Expand Up @@ -276,7 +277,7 @@ export const CompositionInput = ({
} else {
resetEmojiResults();
}
} else if (newSearchText.length >= 2 && focusRef.current) {
} else if (triggerEmojiRegex.test(newSearchText) && focusRef.current) {
setEmojiResults(search(newSearchText, 10));
setSearchText(newSearchText);
setEmojiResultsIndex(0);
Expand Down

0 comments on commit 0beb141

Please sign in to comment.