-
Notifications
You must be signed in to change notification settings - Fork 236
Open
Labels
Component: MenubugSomething isn't workingSomething isn't workingjira ticket createdTODO: Delete label once Jira integration is completeTODO: Delete label once Jira integration is completetriageAn issue needing triageAn issue needing triage
Description
Code of conduct
- I agree to follow this project's code of conduct.
Impacted component(s)
Menu
Library version
1.7.0
Expected behavior
- Item should toggle selection ON and stay selected when pressed via Enter or Space
Actual behavior
- Two
changeevents fire in rapid succession - First event: item selected (e.g.,
['option3']) - Second event: item deselected (e.g.,
[]) - Final state: nothing selected
- Items dont get selected via Space or Enter
Screenshots
No response
What browsers are you seeing the problem in?
Safari, Chrome, Firefox
How can we reproduce this issue?
- Go to this link: https://stackblitz.com/edit/vitejs-vite-o3y6t9td?file=src%2Fmy-element.ts,package.json,src%2Fvite-env.d.ts
- Focus a menu item using arrow keys
- Press Space or Enter
- Observe there is no selection state
Sample code or abstract reproduction which illustrates the problem
File: packages/menu/src/Menu.ts:887-891
The keyboard handler calls selectOrToggleItem() twice:
if (key === ' ' || key === 'Enter') {
event.preventDefault();
root?.focusElement?.click(); // ← Calls handlePointerBasedSelection → selectOrToggleItem
if (root) this.selectOrToggleItem(root); // ← Redundant second call
return;
}The .click() method triggers the click handler, which calls handlePointerBasedSelection(), which calls selectOrToggleItem(). Then the code explicitly calls selectOrToggleItem() again, causing the double-toggle.
Severity
SEV 2
Logs taken while reproducing problem
No response
Would you like to track this issue in Jira?
- Yes, please tell me the ticket number!
Metadata
Metadata
Assignees
Labels
Component: MenubugSomething isn't workingSomething isn't workingjira ticket createdTODO: Delete label once Jira integration is completeTODO: Delete label once Jira integration is completetriageAn issue needing triageAn issue needing triage