Add programmatic search and imperative API#353
Open
daguej wants to merge 2 commits into
Open
Conversation
Owner
|
Hey @daguej , thank you so much for taking the time and effort to work on this. I was abroad this past week, please allow me a few days to go over this change. |
8673ce9 to
d8ad1d4
Compare
e1e9bc5 to
76f2b14
Compare
6f0292c to
d2af775
Compare
467cac6 to
d55c0c3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a few options that allow you to control the emoji picker programmatically.
I'm building inside a
contenteditableeditor, and want users to select emojis by typing in the text area. (Similar to how you can press : in slack or github and get a menu of emojis.) Since users are already typing in an input area, I don't want them to have to move to the search field that is rendered inside the emoji picker; I want to supply the characters the user has typed in my editor and use that to filter the results.This PR supports this use case by adding these options:
search:string- Sets the current search query used to filter the emoji list. This works regardless of whethersearchDisabledis set.onReturnFocus:() => void- IfsearchDisabledis set, this function will be called when user keyboard navigation would have returned focus to the search input field.api:RefObject<EmojiPickerApi>- Provides you access to an imperative API that your component can use. These methods are available:takeFocus()- sets focus to the first interactive element in the picker UI. Similar to pressing ↓ when focus is in the picker's search input.activate()- selects the first visible emoji. Similar to pressing Enter when focus is in the search input.For example:
You can use these three options together to implement pretty seamless search and keyboard navigation glued to an external UI.