[Autocomplete] Add ability to override/compose key down events in autocomplete
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Summary 💡
Developer should have ability to override or compose default onKeyDown functionality
Examples 🌈
Currently when i specify custom onKeyDown prop i’ll get default functionality executed and only then the one i provided.
It makes not possible to override or compose default functionality for specific key pressed.
What i want to be able to do is:
<Autocomplete {...props} onKeyDown={(event, originalHandler) => {
if (['Enter', 'ArrowLeft'].includes(event.key)) {
customHandler(event);
} else {
originalHandler(event)
}
}}>
Motivation 🔦
Motivation is to have ability to override default behaviour for specific event Keys.
Possible use case:
- Need to be able to select options in dropdown with
Space
key and onEnter
key drop down should close and blur out
const onKeyDown = (event, originalFn) => {
switch(event.key) {
case 'Enter':
submitChangesAndFocusOut();
brake;
case 'Space':
selectFocusedItem();
brake;
default:
originalFn(event);
}
}
<Autocomplete {...props} onKeyDown={onKeyDown}>
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:10 (10 by maintainers)
Top Results From Across the Web
[Autocomplete] Add ability to override/compose key down ...
Currently when i specify custom onKeyDown prop i'll get default functionality executed and only then the one i provided. It makes not possible ......
Read more >Overriding keypress event during autocomplete select event
I was using autocomplete, and I wanted to jump specifically to another field after the complete event. So I set focus(). But, the...
Read more >Jetpack Compose – A Simple Opiniated AutoCompleteTextView
So I decided to write my own AutoCompleteTextView to achieve similar behavior. Breaking Down AutoCompleteTextView. At it's core, we rely on two ...
Read more >AutoCompleteTextView - Android Developers
android:dropDownAnchor, View to anchor the auto-complete dropdown to. ... Defines whether this view reacts to context click events.
Read more >Rich text box with mentions and hashtags - Autocomplete
Unlike most autocomplete experiences, the Twitter compose box doesn't process a ... algoliasearch # or yarn add @algolia/autocomplete-core ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ivan-jelev Interesting, we have seen a similar concern raised in #19500. What do you think of my proposal at https://github.com/mui-org/material-ui/issues/19500#issuecomment-580867606? I think that we could move forward with it 😃.
Yes right as i said in the previous comment i didn’t read the case well.
So i can create a PR for this 😃