question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

behavior of up&down keys

See original GitHub issue

Currently when the user moves up and down with the arrow keys a onChange is triggered. If the user hit enter an handleSelect is triggered. But if the user hit tab the list of autocompleteItems is cleared, the input field stay with the tabbed entry and nothing is selected. I think this is the wrong behavior, if the user hit tab is a select and handleSelect should be triggered. Or this behavior should be configurable.

Because if the user moves up and down, he is browsing, and he doesn’t necessarily wants to select anything, if he wants to select something from the list he start moving up and down… And then hit enter, or tab… If he is not happy with any suggestion and just want to leave the input field filled with what he typed earlier he should be able to do so, but currently whatever he does he can’t revert to its typing. Because esc will clear the suggestions but will leave the field with the last entry he browsed, if he hit tab the same will happen.

That would be consistent with the behavior of google search box, if you hit esc you revert the input field to your last typed text, if you hit tab you select. This is already covered by #77 but I can see for some reasons is not merged.

But still I think something should be configurable, because we don’t necessarily want the up and down to trigger an onChange, sometimes you want the user to see the list of suggestion in the form of establishment name + address but maybe we want to keep/use only the address or only the establishment name. There should be some mean of choosing what happen when the user moves up and down, it would be enough to pass a second parameter to onChange signaling if it’s triggered by user typing or browsing the list.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
hibikencommented, Oct 25, 2017

@max-favilli Thank you for this! I agree, google search box (also, search box in Google Maps) is a good example to follow.

I took away a few points from your explanation

  • Pressing esc key should 1) Clear dropdown 2) Revert to last typed in text.
  • Pressing tab key should 1) Clear dropdown 2) Select the highlighted item (if any)

As for 2) in tab key handler, maybe we should allow this to be configurable via prop.

Also, I took a look at Airbnb’s location dropdown, and it has different behavior than Google Maps. I’m open to any suggestions. The library should be flexible but too many options might be confusing for the developer using the library. We need good defaults. I’m happy to make this change, let me know your thoughts @max-favilli 👍

1reaction
grothiercommented, Nov 9, 2017

Hi ! @kenny-hibino I agree too, this would be great if we could use tab to actually select a value !

Read more comments on GitHub >

github_iconTop Results From Across the Web

About Up-Down Controls - Win32 apps | Microsoft Learn
An up-down control is a pair of arrow buttons that the user can click to increment or decrement a value, such as a...
Read more >
Keyboard up/down arrows inconsistent behavior with repo ...
In the repository selector, the behavior of the up and down keyboard keys is inconsistent. It would be great if the down arrow...
Read more >
Flutter override Textfield up / down key behavior - dart
I'm looking for a way to override the behavior of flutters Textfiend up/down keys. Currently they move the cursor to the beginning or...
Read more >
Troubleshooting up/down key behavior in command prompt ...
On my main laptop, running Windows 10 Pro, the up/down arrow keys do not move the selection within the menu, though the Enter...
Read more >
Why has the function of my up & down arrow keys changed ...
Chosen solution. hello Lancs, please press F7 in order to leave caret browsing mode - then the behaviour should be ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found