-
Notifications
You must be signed in to change notification settings - Fork 116
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
Ensure popovers that open dialogs do not close when the dialog opens #2554
Ensure popovers that open dialogs do not close when the dialog opens #2554
Conversation
🦋 Changeset detectedLatest commit: aee75bf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
let node: HTMLElement | null = this.dialog | ||
while (node) { | ||
node = node.closest('[popover]:not(:popover-open)') | ||
if (node) node.showPopover() |
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.
Ah, I see! This block makes sense to me!
269e2d3
to
aee75bf
Compare
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.
Checked:
- Chromium Engine Version 121.0.6167.85
- Firefox 122.0
- Safari 17.3
- Chrome 119
Works as expected on the Dialog inside Overlay preview 👍🏻
Authors: Please fill out this form carefully and completely.
Reviewers: By approving this Pull Request you are approving the code change, as well as its deployment and mitigation plans.
Please read this description carefully. If you feel there is anything unclear or missing, please ask for updates.
What are you trying to accomplish?
Users of the
Primer::Alpha::Overlay
(which uses web nativepopover
) component to create custom floating UI may run into an issue when they nest aPrimer::Alpha::Dialog
(which uses web native<dialog>
) inside of the overlay. This is because at current the algorithm forshowModal()
runs the internalhide all popovers
algorithm. This closes the Overlay, but as the Dialog inside is nested, it will be hidden (display:none
effects all children). This issue is described in whatwg/html#9998 and it is fixed in Chrome 124 (observable in the chromium nightlies). Until all browsers fix it though, we need to work around the issue.One solution for now, is for engineers to not nest dialogs in other floating UI. This is generally a very good idea, however it is also not always completely practical, and so we should cater to engineers with the design system where we can.
Screenshots
Integration
List the issues that this change affects.
Closes # (type the GitHub issue number after #)
Risk Assessment
What approach did you choose and why?
I chose to watch for when our Dialog component opens, to reverse the steps taken by the
hide all popovers
algorithm. This means we will traverse up the tree, looking forpopover
elements that are:popover-open
, andAnything you want to highlight for special attention from reviewers?
Accessibility
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.