Mobius1 / Selectr

A lightweight, vanilla javascript select box replacement. No dependencies.
MIT License
313 stars 77 forks source link

Undo Breaking Changes (from 37bf850) #122

Closed adrian-enspired closed 5 years ago

adrian-enspired commented 5 years ago

re: https://github.com/Mobius1/Selectr/pull/51

After tabbing to a selectr element, pressing the typical keyboard activation keys (space, up/down) wouldn't open the selectr container. Pressing Enter wouldn't submit the form (or do anything).

After dismissing the dialog (e.g. via pressing enter), the tab focus was lost thus starting you back over at the top of the document (making using keyboard only navigation painful).

These behaviors (except form submission on Enter; see below) already exist in Selectr. To enable them, you should set config.nativeKeyboard = true. Personally, I would be in favor of enabling them by default, which might also prevent confusion like this in the future.

Unfortunately, these changes did not simply duplicate existing behavior, but caused some problems as well:

Suggestions for future changes:

If there is some standard keyboard behavior that is missing from Selectr, if should be added behind the nativeKeyboard config option.

If there is some nonstandard keyboard behavior that is deemed desirable, it should be added behind its own config option, or, if added globally, should be disabled when the nativeKeyboard option is enabled.

TL;DR:

Set config.nativeKeyboard = true instead.