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

special case anchored-position for top-layer elements #195

Merged
merged 2 commits into from
May 11, 2023

Conversation

keithamus
Copy link
Member

@keithamus keithamus commented May 10, 2023

When calculating the positioning for an anchored position element, the current algorithm traverses the tree to find "positioned parents"; that is parents with a non-default overflow or position.

This is acceptable for most elements, but native <dialog> and elements with popover= get reflected onto the :top-layer element, which is adjacent to the document, and therefore layout should be calculated using the main viewport, not any overflow/position parents.

This PR adds a check to special case such elements, by checking if the element is a dialog, or by checking if the :popover-open psuedo class is active. Sadly there is no pseudo selector to detect whether or not an element is on the top layer, so we have to check for likely candidates instead.

Fixes primer/view_components#2000

@keithamus keithamus requested review from a team and siddharthkp May 10, 2023 16:59
@changeset-bot
Copy link

changeset-bot bot commented May 10, 2023

🦋 Changeset detected

Latest commit: bddd6c5

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

This PR includes changesets to release 1 package
Name Type
@primer/behaviors 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

@keithamus keithamus merged commit 3f2f45a into main May 11, 2023
@keithamus keithamus deleted the special-case-anchored-position-for-top-layer-elements branch May 11, 2023 09:49
@primer-css primer-css mentioned this pull request May 11, 2023
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.

Overlays are positioned incorrectly in Chrome Dev channel with Experimental Web Platform features enabled.
1 participant