Skip to content
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

document preventFocusOnOpen prop in useOpenAndCloseFocus and useOverlay hooks #926

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

ktravers
Copy link
Contributor

@ktravers ktravers commented Feb 6, 2025

Related: primer/react#5636

This PR documents the preventFocusOnOpen prop available for use in the useOpenAndCloseFocus and useOverlay hooks. This prop was introduced here, and has been available for at least four years.

Despite being undocumented, it's used fairly regularly, usually via the Overlay and Autocomplete components.

@ktravers ktravers self-assigned this Feb 6, 2025
@ktravers ktravers requested a review from a team as a code owner February 6, 2025 20:46
@ktravers ktravers requested a review from Copilot February 6, 2025 20:47

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Tip: Turn on automatic Copilot reviews for this repository to get quick feedback on every pull request. Learn more

ktravers added a commit to primer/react that referenced this pull request Feb 6, 2025
@ktravers ktravers changed the title document preventFocusOnOpen prop in useOpenAndCloseFocus hook document preventFocusOnOpen prop in useOpenAndCloseFocus and useOverlay hooks Feb 6, 2025
Copy link
Contributor

@camertron camertron left a comment

Choose a reason for hiding this comment

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

Cool, thank you!

@camertron camertron merged commit e845189 into main Feb 6, 2025
6 checks passed
@camertron camertron deleted the ktravers/document-prevent-focus-on-open branch February 6, 2025 21:38
github-merge-queue bot pushed a commit to primer/react that referenced this pull request Feb 8, 2025
* only prevent focus when component is open

Otherwise, prevents focus from returning to given returnFocusRef.

* fixup callback

* add component tests asserting expected behavior

* update hook tests

* add changeset

* add dev story for preventFocusOnOpen

* document preventFocusOnOpen prop

Based on hooks docs:
* https://primer.style/guides/react/hooks/use-open-and-close-focus

Related:
* primer/design#926
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants