Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰amp-autocomplete: Fix submit-on-enter bug #21800

Merged
merged 4 commits into from Apr 23, 2019

Conversation

caroqliu
Copy link
Contributor

@caroqliu caroqliu commented Apr 10, 2019

This PR fixes a submit-on-enter bug wherein submit-on-enter="false" fails to prevent form submission when Enter is pressed while suggestions are displaying. The updated behavior is as follows: submit-on-enter="true" does not disrupt any consequences of pressing Enter in the containing input field of an amp-autocomplete. submit-on-enter="false" will prevent default behavior only if suggestions are displayed. This is because the default consequences of pressing Enter should only be disrupted when there is a new interaction pattern for it, such as selecting an item from a list of suggestions, which is not possible when no suggestions are displayed.

  • Fixes the aforementioned bug
  • Updates tests and documentation to reflect changes
  • Fixes related logic with setting and resetting activeElement_ and activeIndex_

@caroqliu caroqliu changed the title 馃悰amp-autocomplete: Fixed submit-on-enter bug 馃悰amp-autocomplete: Fix submit-on-enter bug Apr 10, 2019
Copy link
Contributor

@cvializ cvializ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@cvializ cvializ merged commit 4d6f10e into ampproject:master Apr 23, 2019
@caroqliu caroqliu deleted the submit-on-enter-bug branch September 6, 2019 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants