Skip to content

fix: Ensure that opening a submenu via enter/space moves focus to first item in submenu#9691

Open
LFDanLu wants to merge 1 commit intomainfrom
fix_9686
Open

fix: Ensure that opening a submenu via enter/space moves focus to first item in submenu#9691
LFDanLu wants to merge 1 commit intomainfrom
fix_9686

Conversation

@LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented Feb 24, 2026

Closes #9686

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Go to RAC Submenu story and make sure that Enter/Space opens the submenu and that focus lands on the first item in the submenu. Pressing Enter/Space again should trigger the submenu item

🧢 Your Project:

RSP

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried writing a test for this but it passes without the change since the timing isn't quite the same as in browser. Will be worth writing one in chromatic using the actions or via the real browser test PR when that goes in

@rspbot
Copy link

rspbot commented Feb 24, 2026

interaction.current = {pointerType: 'keyboard', key: ' '};
(getEventTarget(e) as HTMLElement).click();

// click above sets modality to "virutal", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// click above sets modality to "virutal", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
// click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus

Comment on lines +303 to +304
// click above sets modality to "virutal", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
// to the newly opened submenu's first item.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// click above sets modality to "virutal", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
// to the newly opened submenu's first item.
// click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
// to the newly opened submenu's first item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot invoke action with "enter" key on first menu item of submenu after opening submenu with "enter" key.

3 participants