Open Bug 2014997 Opened 9 months ago Updated 8 months ago

CSS Anchor Positioning: `position: absolute` element fails to anchor to `position: fixed` element

Categories

(Core :: Layout, defect, P3)

Firefox 147
defect

Tracking

()

UNCONFIRMED

People

(Reporter: lucacasonato, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Attached image broken_in_firefox.png —

To reproduce:

  1. https://console.deno.com and create an account
  2. Create an organization, click on "Settings"
  3. Click on "Create new Environment Variable"
  4. Click on "Add variable"
  5. Click on "Contexts" dropdown

The popover is rendered at the top left of the page (see screenshot 1, from Firefox).

The popover should render under the popover trigger (see screenshot 2, from Chrome).

I can make it behave by removing the position: absolute, but I shouldn't have to do that. position: absolute with anchor-position: --... set should anchor to the anchor, not to the top left of the page.

It also works for the exact same component if it is not in a dialog.

Chrome behaves the way I expect. Firefox fails in 147, 148, and 149

I've also opened a webcompat issue: https://github.com/webcompat/web-bugs/issues/205938

Attached image working_in_chrome.png —

I didn't mean to mark this as security sensitive - can someone please unmark?

Group: core-security

Making the popover position:fixed rather than position:absolute fixes this. I'll get a reduced test case together for the issue.

https://random-stuff.jakearchibald.com/bug-repros/anchor-popover-absolute/ - here's a minimalish reproduction.

The issue is when the anchor-positioned element is position:absolute but anchored to a position:fixed element.

Summary: CSS Anchor Positioning broken on console.deno.com → CSS Anchor Positioning: `position: absolute` element fails to anchor to `position: fixed` element
Duplicate of this bug: 2015012

So I think this is actually a bug on Chrome/Safari side - Fixed elements parent to viewport, where absolute elements frame to the document. The implication is that the fixed element, i.e. the anchor in this case, lays out after the absolute element, i.e. the positioned element in this case, which violates the assumption required for acceptable anchor element.

In fact, with :jakea's example, making the page scroll by e.g. adding <div style="height: 200vh;"></div> to the end and scrolling, you will see that the positioned element simply scrolls away on Chrome.

I agree with your reading here :dshin.

The severity field is not set for this bug.
:boris, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(boris.chiou)
Severity: -- → S3
Flags: needinfo?(boris.chiou)
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: