Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Undo Breaking Changes (from 37bf850) #122

Merged
merged 1 commit into from
May 31, 2019

Conversation

adrian-enspired
Copy link
Contributor

re: #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:

  • The event listeners that were added/modified were previously only set up when the nativeDropdown option was enabled, but are now set up unconditionally.
    This causes conflicts and duplicated events when nativeKeyboard is enabled.

  • Making Enter submit the form when a <select> element is focused is unexpected and often undesired.
    When a select box is focused, normal browser behavior when pressing Enter is to open the select box (or select an option if already open).
    Implicit form submission should only happen when a form <input> is in focus.
    See the whatwg standard for more info: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission

  • returning focus to the select container when closing it is also (imo) unexpected, but, more importantly, cause focus to become "stuck" on the selectr in some cases.
    For example, if an onBlur event listener calls close() on the select, then focus will immediately return to it, and the form (potentially, the entire page) becomes unusable.
    When using nativeKeyboard, closing the select via Enter or Escape does not cause focus to be lost.

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.

@Mobius1 Mobius1 merged commit 93313bb into Mobius1:master May 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants