Skip to content

Conversation

chirokas
Copy link
Contributor

Closes #8791

When a MenuItem is triggered via keyboard, it enters the virtual interaction mode (see the related code here). In this mode, the focusSafely function defers focus using runAfterTransition. However, by the time the callback is executed, the MenuItem (i.e., the lastFocusedElement) has already been unmounted. As a result, focus falls back to the body, causing focus failure.

✅ 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:

🧢 Your Project:

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

I think this is fine. We'll want to focus testing around leaving the browser/coming back either though visiting another application or switching tabs and with submenus.

Thanks for the PR!

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.

Input autoFocus doesn't work when Modal opened from MenuItem via keyboard
2 participants