-
Notifications
You must be signed in to change notification settings - Fork 585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onSuggestionSelected now fires when receiving key press of Tab or ArrowRight #333
Conversation
It would be nice if right arrow did this as well. |
I'll see if I can add that to this PR too, probably only next week though. |
Whats the progress on this? |
I think this should preferably be opt-in behaviour (with a bool prop). That way not everyone is forced to select a suggestion on blur, but those who want to can easily. |
Added the right arrow press as well. |
Hi @moroshko can you please add @Jackleberry changes in master? I really need this. |
@moroshko Apologies for the spam, but any chance to get this merged/released soon? I too really need this for my application. |
@Jackleberry Sorry for such a delayed response. Selecting a suggestion when → is pressed seems wrong to me. Imagine the following scenario:
It doesn't seem reasonable to me to call When Tab is pressed, the default and expected behavior on the web is to move the focus to the next element and blurring the Autosuggest input. This is exactly what's happening at the moment. Could you explain what problem are you trying to solve by calling Would you consider the suggestion being selected (i.e. would you call |
@moroshko I agree with the first point, and I see what you're saying with the second. I think I have a general frustration about the default tab functionality, however what you've said is they way it should work. I'll close the PR. |
You could argue the same way that pressing Enter inside an input, the default and expected behavior on the web is to submit the form. For my use case, I only have a single input, so there is nothing the user could Tab to. I would like to reserve Enter for submitting the search and Tab for selecting different (potentially multiple) suggestions, as known from code editor/IDE autocompletion. |
This is true, but having the option to additionally select the first highlighted item matches the behavior of a
In cases where only the suggested items are valid options and the autosuggest is functioning as a searchable select, I think it makes sense to allow selecting with One more small bit of functionality which goes with this is clearing the input on When doing a basic suggestion list, I think you could implement the functionality on top of the component using onBlur, however if you do a |
Hi @moroshko, Now what he/she will do? -->, of course, he/she will imagine that his desired suggestion is selected because it's highlighted and press tab. But nothing is selected, so he/she have to come back and select it again to successfully proceed with the form. |
I have added in a one liner to allow onSuggestionSelected to fire when pressing the 'Tab' button.
I have added tests and updated the documentation and npm run build works.