Skip to content

test(hotkey): add coverage for alternate (/) key combinations#22716

Open
mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
mixelburg:test/hotkey-alternate-support
Open

test(hotkey): add coverage for alternate (/) key combinations#22716
mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
mixelburg:test/hotkey-alternate-support

Conversation

@mixelburg
Copy link
Copy Markdown
Contributor

Summary

Closes #22712

The useHotkey composable parses the / character as an alternate separator (e.g. 'up/down' means "fire on ArrowUp or ArrowDown"), yet the test suite had zero coverage for this code path.

What was reported

In #22712, a user found that pressing the first key of an alternate combination ('1' in '1/2') did not trigger the callback, while pressing the last key ('2') did work.

What these tests cover

Test What it checks
each alternative triggers callback independently '1/2' → '1' fires; '1/2' → '2' fires
arrow key alternates 'up/down' → ArrowUp and ArrowDown each fire
modifier + key alternates 'ctrl+a/ctrl+b' fires for each combo
shift variations 'shift+tab/tab' fires for both shifted and unshifted Tab
unrelated key ignored pressing 'c' on hotkey 'a/b' does nothing
alternate inside sequence 'a/b-c' means (a OR b), then c — tests both entry points

If the alternate matching logic is broken for the first element (as #22712 describes), the '1/2' → '1' and similar tests will surface the regression.

The useHotkey composable supports the '/' syntax for alternate key
combinations (e.g. 'up/down' fires for either ArrowUp or ArrowDown),
but the test suite had zero coverage for this case.

This was reported in issue vuetifyjs#22712, where pressing the first key in an
alternate combination ('1' in '1/2') did not trigger the callback while
pressing the last one ('2') did.

Add tests that:
- verify every alternative in a combo independently fires the callback
- confirm unrelated keys are ignored
- ensure alternates work inside a longer sequence ('a/b-c')

Refs: vuetifyjs#22712
@J-Sek
Copy link
Copy Markdown
Contributor

J-Sek commented Mar 15, 2026

I don't think the code is so brittle it needs 2 middle test cases. The 1st and the 4th feel enough.

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.

[Bug Report][4.0.2] useHotkey doesn't support '/' modifier as documented

2 participants