react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

[v2.x] AutocompleteInput should accept selection on Enter

Open thoat opened this issue 6 years ago • 3 comments

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 avatar Dec 14 '19 03:12 thoat

Some gifs to illustrate:

Before fix:

ra-autocomp-input-before

After fix:

ra-autocomp-input-after

thoat avatar Dec 14 '19 04:12 thoat

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

developerium avatar Jan 27 '20 10:01 developerium

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

alixdeschamps avatar Mar 04 '20 09:03 alixdeschamps