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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v-on): avoid events with empty keyCode (autocomplete) #11326

Merged
merged 1 commit into from
Apr 16, 2021

Conversation

zupolgec
Copy link
Contributor

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

The PR fulfills these requirements:

Other information:

Chromium browsers (and Safari) trigger a keydown/keyup event on autocomplete. An Event object without key or keyCode is generated.
Vue, when listening with modifiers, is triggering the callback even if the modifier key doesn't match the undefined keyCode of the event.

Current behaviour: https://codepen.io/zupolgec/pen/RwWRxdK
New behaviour: https://codepen.io/zupolgec/pen/qBONxMj

Try autocompleting the first field: in the first demo is counted, in the second demo is ignored.

See also same kind of issue on another JS library: alpinejs/alpine#389 (comment)

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

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

This would indeed make the behavior consistent across browsers (e.g. Firefox doesn't trigger a keyup)!

Related commit: 29c348f

@posva posva changed the title fix(v-on): stop triggering callback on key* events with modifier but without key info (e.g. autocomplete) fix(v-on): avoid events with empty keyCode (autocomplete) Apr 16, 2021
@posva posva merged commit c6d7a6f into vuejs:dev Apr 16, 2021
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.

2 participants