File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,9 +32,9 @@ export default function App() {
3232
3333 const suggestions = useMemo ( ( ) => {
3434 if ( ! open ) return [ ] ;
35- // A trailing ":" (as in ":smile:") is part of the query - drop it.
36- const q = query . replace ( / : $ / , '' ) . toLowerCase ( ) ;
37- return EMOJIS . filter ( emoji => emoji . shortcode . startsWith ( q ) ) ;
35+ return EMOJIS . filter ( emoji =>
36+ emoji . shortcode . startsWith ( query . toLowerCase ( ) )
37+ ) ;
3838 } , [ open , query ] ) ;
3939
4040 const openPicker = ( ) => {
@@ -50,6 +50,16 @@ export default function App() {
5050 const updateQuery = ( { text } : OnChangeMentionEvent ) => {
5151 setOpen ( true ) ;
5252 setQuery ( text ) ;
53+
54+ if ( text . endsWith ( ':' ) ) {
55+ const strippedQuery = text . slice ( 0 , text . length - 1 ) ;
56+ const autoChosenEmoji = EMOJIS . find (
57+ emoji => emoji . shortcode === strippedQuery
58+ ) ;
59+ if ( autoChosenEmoji ) {
60+ pick ( autoChosenEmoji ) ;
61+ }
62+ }
5363 } ;
5464
5565 const pick = ( emoji : Emoji ) => {
You can’t perform that action at this time.
0 commit comments