Closed Bug 2003738 Opened 23 hours ago Closed 13 hours ago

Anchor Positioning Compat Issue: Anchored items take up the entire containing block

Categories

(Core :: Layout: Positioned, defect)

Firefox 147
defect

Tracking

()

RESOLVED DUPLICATE of bug 1991929

People

(Reporter: bramus, Unassigned)

Details

Attachments

(3 files)

Steps to reproduce:

DEMO: https://codepen.io/bramus/pen/YPqjgMq

Actual results:

(Without the fix) this demo is behaving differently than Chrome/Safari.

To make Firefox Nightly [147.0a1 (2025-12-02) (aarch64)] behave, I needed to declare this on the .anchored elements:

width: min-content;
height: min-content;

If you remove these two declarations, the .anchored boxes take up their full containing block.

Expected results:

Given that Safari and Chrome agree no what should happen here, I think that’s what should also happen in Firefox.

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Positioned' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: General → Layout: Positioned

Here's a standalone testcase, using the HTML/CSS from the codepen (without the min-content declarations that are present in the codepen to make it work in Firefox).

I can reproduce the beavior-difference in this testcase; Firefox fills the viewport with the blue labels, whereas Chrome sizes those labels to their content.

Attached file testcase 2 (reduced)

Here's a further-reduced testcase.

In Firefox, the anchor-positioned auto-sized element with bottom span-right extends to the bottom and right edge of the viewport; in Chrome, it shrinks-to-fit its contents.

This reference case demonstrates that if I give the element an explicit size, then it doesn't stretch, as bramus observed in comment 0.

jwatt or dshin, could you take a look?

(Tentatively triaging as S3; but depending on the anticipated impact, we might want to consider it S2, and aim to fix before anchor makes it to release.)

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(mozmail)
Flags: needinfo?(dshin)

It's bug 1991929. Intended behaviour should be equivalent to:

width: fit-content;
height: fit-content;

Or, more indirectly,

align-self: start;
justify-self: start;
Status: NEW → RESOLVED
Closed: 13 hours ago
Duplicate of bug: 1991929
Flags: needinfo?(mozmail)
Flags: needinfo?(dshin)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: