Skip to content

[Bug]: Menu Multiple Selection Keyboard Issues #5825

@Rajdeepc

Description

@Rajdeepc

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 change events 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?

  1. Go to this link: https://stackblitz.com/edit/vitejs-vite-o3y6t9td?file=src%2Fmy-element.ts,package.json,src%2Fvite-env.d.ts
  2. Focus a menu item using arrow keys
  3. Press Space or Enter
  4. 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

No one assigned

    Labels

    Component: MenubugSomething isn't workingjira ticket createdTODO: Delete label once Jira integration is completetriageAn issue needing triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions