-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(autocomplete): close dropdown on enter or tab key press (#761)
* fix(autocomplete): close after selection When an autocomplete value is selected via the autocomplete's `setSelected()` method, the autocomplete's v-model value will usually be updated, and the dropdown will usually scheduled to be closed on the next tick. However, updating the v-model value triggers the v-model watcher, which would then schedule the dropdown to be open again on the next tick. This change updates the v-model watcher to not do anything when the new value is the same as the currently selected value. * fix(autocomplete): close on blur If the autocomplete looses focus without a mouse click (eg because the user tabbed away from it), the dropdown would remain open. This change extends the standard onBlur handler to first close the dropdown (and then run the standard onBlur handling). * fix(autocomplete): remove menu from tab sequence Pressing the tab key when the autocomplete input was focused moved the focus to autocomplete menu. This change removes the autocomplete menu and all of its options from the tab sequence. * fix(autocomplete): clear itemRefs on re-render Using the up & down keys to change the "hovered" state triggers a re-render of the autocomplete menu options -- but not of the autocomplete component itself. The autocomplete's own `onBeforeUpdate` handler is not called when this happens; and so using it to clear the `itemRefs` array resulted in the previous set of options not being removed. The main manifestation of this bug was that it was not possible to use the down key to access a selectable-footer option. This change clears the `itemRefs` array whenever the `setItemRef()` function is called for the first menu option; now the `itemRefs` array will be cleared both whenever the full autocomplete component is re-rendered, and whenever just the individual options are re-rendered. * fix(autocomplete): select head/foot exclusively When the `selectable-header` (or `selectable-footer` prop) is true, it was possible to use the up & down keys to turn on the visual "hovered" state for both the header (or footer) option and another regular option at the same time. This change centralizes the logic of setting the `hoveredOption`, `headerHovered`, and `footerHovered` refs in the `setHovered()` function, ensuring that only one can be set at a time. * fix(autocomplete): apply aria combox pattern The ARIA attributes used by the autocomplete menu and options represented the menu as if it were a standalone modal dialog. The change applies the Combobox Pattern from the ARIA Authoring Practices Guide to the autocomplete input, menu, and options -- which should allow assistive technologies to recognize the menu as a list of options available for the input, and to identify the currently "hovered" option. See https://www.w3.org/WAI/ARIA/apg/patterns/combobox/ for details.
- Loading branch information
1 parent
0a7f9b4
commit 796ed9f
Showing
5 changed files
with
112 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.