-
Notifications
You must be signed in to change notification settings - Fork 648
ActionBar: Add ability to change focus target on menu close #7400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 43e5000 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds focus management flexibility to the ActionBar component by introducing a new returnFocusRef prop to ActionBar.Menu. This allows developers to specify a custom focus target when the menu closes, instead of defaulting to the anchor button.
Key Changes
- Added
returnFocusRefprop toActionBar.Menucomponent that accepts a ref to an HTMLElement - Integrated the prop throughout the component hierarchy, including overflow menu rendering
- Added comprehensive test coverage for the new functionality including escape key, item selection, and default behavior scenarios
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/react/src/ActionBar/ActionBar.tsx |
Added returnFocusRef prop to type definitions, threaded it through the component hierarchy, and passed it to ActionMenu.Overlay in both direct usage and overflow menu contexts |
packages/react/src/ActionBar/ActionBar.test.tsx |
Added four comprehensive tests covering prop acceptance, focus return on escape, focus return on item selection, and default behavior when prop is not provided |
packages/react/src/ActionBar/ActionBar.docs.json |
Added documentation for the new returnFocusRef prop with clear description of its purpose |
.changeset/curvy-walls-exist.md |
Added changeset entry for the new feature (though version should be minor not patch) |
Co-authored-by: Copilot <[email protected]>
Closes https://github.com/github/primer/issues/6117
Adds new prop to
ActionBar.Menu, allowing developers to specify where focus should return when the menu is closed via the newreturnFocusRefprop.Changelog
New
returnFocusRefprop toActionBar.MenuRollout strategy
Testing & Reviewing
Merge checklist