-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Search with autocomplete: Work around Enter edge case
The `accessible-autocomplete` component has an edge case where when the menu is visible, it `preventDefault()`s on the Enter key event, even if the user hasn't put keyboard focus on a suggestion. This results in a scenario where the user types something, does _not_ interact with the autocomplete menu at all, and then hits Enter to try to submit the form - but it isn't submitted. This is not something we can fix upstream as it is usually desirable behaviour for the library, so we implement a workaround that adds our own event listener and ensure `requestSubmit` is run for the form if it hasn't been already. - Add event listener for `keydown` event and submit the containing form ourselves if the key is `Enter` - Split out code meant to run on accepting a suggestion (`onConfirm`) from form submission logic (`submitContainingForm`) so we can reuse the latter - Add a check to `submitContainingForm` that it hasn't already been called for the component anyway
- Loading branch information
Showing
3 changed files
with
53 additions
and
10 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