Skip to content

fix: use standard key values for trigger key modifiers - #3041

Merged
cexbrayat merged 1 commit into
vuejs:mainfrom
ValentinYoushkevich:fix/trigger-key-modifier-names
Nov 23, 2026
Merged

cexbrayat merged 1 commit into
vuejs:mainfrom
ValentinYoushkevich:fix/trigger-key-modifier-names

Conversation

@ValentinYoushkevich

@ValentinYoushkevich ValentinYoushkevich commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

trigger('keydown.esc') sets event.key to 'esc', while browsers send 'Escape'. Handlers written against real keys don't fire in tests:

<input @keydown.escape="close" /> <!-- same for .arrow-left, .page-down -->
await wrapper.trigger('keydown.esc') // close() is not called

Same for e.key === 'Enter' checks after trigger('keydown.enter'). Libraries work around it with trigger('keydown', { key: 'Escape' }), e.g. oruga (for this listener).

This sets key from a map next to codesByKeyName, as #2850 did for code: 'Escape', 'ArrowLeft', ' ', etc. Vue's short modifiers (.esc, .left, .space, .delete) still match, and unknown modifiers (keydown.a, keydown.Escape) are unchanged.

Existing tests that relied on the old values will fail, and in each case the code under test doesn't work in a browser:

  • checks of event.key against 'enter', 'esc', 'left', ... (like the three assertions updated here);
  • @keydown.pageup / @keydown.pagedown listeners: Vue only matches .page-up / .page-down for a real PageUp / PageDown.

Related: #1852, #2544

Playground: playground (@vue/test-utils 2.6.0)

@netlify

netlify Bot commented Nov 19, 2026

Copy link
Copy Markdown

👷 Deploy request for vue-test-utils-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 1a2f499

@pkg-pr-new

pkg-pr-new Bot commented Nov 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vue/test-utils@3041

commit: 1a2f499

@cexbrayat
cexbrayat merged commit 530d4de into vuejs:main Nov 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants