-
Notifications
You must be signed in to change notification settings - Fork 246
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
Bug: Keydown events supply incorrect values for event.code #2544
Comments
Yes, I think this behavior is there for backward compatibility (see test-utils/src/createDomEvent.ts Lines 102 to 117 in 3988a31
Feel free to open a PR if you think that could be omproved without breaking existing applciations 👍 |
What kind of backwards compatability are we talking here? To my knowledge Event.code has never used to house the keyCode. |
keyCode was a thing but is deprecated https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode But as I said, we're welcoming any contribution to improve this use case |
Yes I understand keyCode was deprecated but "code" wasn't and was never used to save a number. |
Actually looking at your code snippet it seems this issue would already be partially solved if a new version was built due to #2434 which would at least allow the 2nd test case in the repro to succeed |
Describe the bug
When using element.trigger('keydown.xyz'), some keys incorrectly pass the keyCode as code to handlers of KeyboardEvents.
This fundamentally breaks testing for keyboard navigation when f.ex. a dropdown has to be tested for keydown.home, keydown.end, space and enter where a handler with check for event.code is the best practice
To Reproduce
https://stackblitz.com/edit/github-bbenms?file=src%2FButton.vue&view=editor
->
Event.code logs a string representation of Event.keyCode for various keys.
Tested keys that do not work correctly: Home, End, Enter, Space, Escape
Expected behavior
Event.code should correctly log the name of the key
Related information:
Additional context
The text was updated successfully, but these errors were encountered: