Skip to content
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

[v2.x] AutocompleteInput should accept selection on Enter #4167

Closed
thoat opened this issue Dec 14, 2019 · 3 comments
Closed

[v2.x] AutocompleteInput should accept selection on Enter #4167

thoat opened this issue Dec 14, 2019 · 3 comments

Comments

@thoat
Copy link

thoat commented Dec 14, 2019

Not sure if this is a bug or is intended.

User context

My users would navigate up and down the suggestion list using the UpArrow and DownArrow key. When they see their desired choice, they hit Enter. However, that choice/that selection is not recorded. The only to way to record it is to reach for the mouse and click on the item.

My troubleshooting

I went into the source code of AutocompleteInput v2.x and found this code is what causes that behavior:

handleChange = (event, { newValue, method }) => {
   if (['type', 'click', 'escape'].includes(method)) {
      this.handleMatchSuggestionOrFilter(newValue);
   }
};

When I added enter to the trio, I got the behavior that my users want:

if (['type', 'click', 'escape', 'enter'].includes(method)) {

My ask

Before viewing this as a bug or a feature request, I'd love to know if react-admin team had some rationale for including these 3 methods but not the enter method. I'm considering, if it's not possible to add enter in react-admin source code, I probably will have to copy the implementation of AutocompleteInput to my project to override just that single line.

@thoat
Copy link
Author

thoat commented Dec 14, 2019

Some gifs to illustrate:

Before fix:

ra-autocomp-input-before

After fix:

ra-autocomp-input-after

@developerium
Copy link
Contributor

Hi @thoat
Can you make that fix into a pull request?
I haven't checked the code, so I don't know if that's the best way to go

@alixdeschamps
Copy link

Hi @thoat ,
This feature exists in the version I'm using (3.1.2). Try updating your react-admin version

@djhi djhi closed this as completed Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants