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

Ensure popovers that open dialogs do not close when the dialog opens #2554

Conversation

keithamus
Copy link
Member

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 native popover) component to create custom floating UI may run into an issue when they nest a Primer::Alpha::Dialog (which uses web native <dialog>) inside of the overlay. This is because at current the algorithm for showModal() runs the internal hide 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

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

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 for popover elements that are :popover-open, and

Anything you want to highlight for special attention from reviewers?

Accessibility

  • Fixes axe scan violation - This change fixes an existing axe scan violation.
  • No new axe scan violation - This change does not introduce any new axe scan violations.
  • New axe violation - This change introduces a new axe scan violation. Please describe why the violation cannot be resolved below.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@keithamus keithamus requested review from a team and jonrohan February 1, 2024 10:41
Copy link

changeset-bot bot commented Feb 1, 2024

🦋 Changeset detected

Latest commit: aee75bf

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

This PR includes changesets to release 1 package
Name Type
@primer/view-components Patch

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 Feb 1, 2024

⚠️ Visual differences found

Our visual comparison tests found UI differences. Please review the differences by viewing the files changed tab to ensure that the changes were intentional.

Review visual differences

let node: HTMLElement | null = this.dialog
while (node) {
node = node.closest('[popover]:not(:popover-open)')
if (node) node.showPopover()
Copy link
Member

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!

@keithamus keithamus force-pushed the ensure-popovers-that-open-dialogs-do-not-close-when-the-dialog-opens branch from 269e2d3 to aee75bf Compare February 1, 2024 10:53
Copy link
Member

@jonrohan jonrohan left a 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 👍🏻

@camertron camertron merged commit 652e795 into main Feb 1, 2024
30 checks passed
@camertron camertron deleted the ensure-popovers-that-open-dialogs-do-not-close-when-the-dialog-opens branch February 1, 2024 18:28
@primer primer bot mentioned this pull request Feb 1, 2024
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.

4 participants