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

Overlay: Add role="dialog", focus trap to Overlay #4990

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

TylerJDev
Copy link
Contributor

@TylerJDev TylerJDev commented Sep 19, 2024

Closes https://github.com/github/primer/issues/3378

Usages of Overlay tend to lean more towards a dialog across GH. This PR aims to define it as a dialog in most cases, provided with a focus trap that's toggled via the newly added focusTrap prop.

Changelog

New

  • Add role="dialog" and aria-modal="true" to Overlay component

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

Copy link

changeset-bot bot commented Sep 19, 2024

🦋 Changeset detected

Latest commit: 5627e4f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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

Copy link
Contributor

github-actions bot commented Sep 19, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 97.85 KB (+0.02% 🔺)
packages/react/dist/browser.umd.js 98.16 KB (+0.1% 🔺)

@TylerJDev TylerJDev changed the title Overlay: Add role="dialog", focus trap to Overlay` Overlay: Add role="dialog", focus trap to Overlay Sep 19, 2024
@github-actions github-actions bot temporarily deployed to storybook-preview-4990 September 19, 2024 14:38 Inactive
@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/343407

@TylerJDev
Copy link
Contributor Author

This change essentially turns Overlay into a "Dialog" in the sense of role="dialog" and aria-modal="true" being added. A focus trap is also added by default, and is enabled if there are focusable elements inside of the overlay. This change will not affect overlays that already have a role attribute, as long as that role attribute isn't role="dialog".

Rollout plan:

  • Add role="none" to existing Overlay components that do not implicitly set role already
  • Add focusTrap={false} to Overlay components that are used as Dialogs currently, but do not utilize a focus trap.

@@ -109,6 +110,7 @@ type BaseOverlayProps = {
portalContainerName?: string
preventFocusOnOpen?: boolean
role?: AriaRole
focusTrap?: boolean
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a new prop in case there's an implementation that wants to be a dialog, but doesn't want the focus trap applied. This is a very specific case, and ideally won't be necessary in more than a handful of instances.

@TylerJDev TylerJDev marked this pull request as ready for review September 20, 2024 23:22
@TylerJDev TylerJDev requested a review from a team as a code owner September 20, 2024 23:22
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.

1 participant