Open Bug 1989495 Opened 2 months ago Updated 1 month ago

"grid-template-rows: 1fr auto" causes incorrect width calculation for first row when first child has some aspect-ratio

Categories

(Core :: Layout: Grid, defect, P3)

Firefox 144
defect

Tracking

()

People

(Reporter: alejandro9r, Unassigned, NeedInfo)

References

Details

Attachments

(2 files)

Steps to reproduce:

Firefox incorrectly calculates the width of the first grid row when using grid-template-rows: 1fr auto in combination with a child element that has aspect-ratio.

The issue specifically occurs when the second row uses auto sizing. When changing grid-template-rows: 1fr auto to grid-template-rows: 1fr 2rem (or any explicit size), the width calculation becomes correct and matches other browsers. Happens with standard images or elements, as long as there is a aspect-ratio to be followed.

Test case:
https://codepen.io/Arecsu/pen/myVdWLp

Workaround:
Replace auto with an explicit size in grid-template-rows (e.g., 1fr 2rem). This could defeat some responsive layouts though.

Affected versions:
Firefox 143
Firefox Nightly 144

Other browsers:
Works correctly in Chrome and Safari.

Actual results:

The first row gains extra/incorrect width, causing the grid items to be wider than they should be. The area becomes oversized compared to other browsers.

Expected results:

The first row (containing the image) should maintain proper aspect ratio constraints and not expand beyond necessary width, like on Chrome/Safari.

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

Component: Untriaged → Layout: Grid
Product: Firefox → Core

So behavior here used to be much worse until bug 1957244. Ting-Yu, maybe some minor bit missing here?

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(aethanyc)
Priority: -- → P3
See Also: → 1957244
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: