Bug 246451 - Layout of nested grid with padding and aspect ratio fails
Summary: Layout of nested grid with padding and aspect ratio fails
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari 16
Hardware: Mac (Apple Silicon) macOS 12
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2022-10-13 04:02 PDT by Johannes Odland
Modified: 2023-06-18 11:11 PDT (History)
6 users (show)

See Also:


Attachments
Screenshot in Safari (14.65 KB, image/png)
2022-10-13 04:02 PDT, Johannes Odland
no flags Details
Screenshot in Chrome (45.38 KB, image/png)
2022-10-13 04:02 PDT, Johannes Odland
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Odland 2022-10-13 04:02:01 PDT
Created attachment 462956 [details]
Screenshot in Safari

Element in grid container with aspect-ratio, padding and align-content: end is placed outside grid if grid container is nested in another grid container.

I have replicated the bug in the following code pen: https://codepen.io/johannesodland/pen/xxjMgzr

```html
  <section>
    <div class="hero">
      <h2>Title</h2>
    </div>
  </section>

```

```css
:root {
  --_padding: 15px;
}

section {
  display: grid;
}

.hero {
  display: grid;
  background-color: silver;
  aspect-ratio: 16 / 9;
  padding: var(--_padding);
  align-content: end;
  justify-items: start;
}

h2 {
  margin: 0;
  padding: var(--_padding);
  background: mediumorchid;
}

```

Expected result: h2 is rendered inside padding at the bottom of the containing grid element.
This is correct in Chrome and Firefox.

Actual result: h2 is rendered 2 x padding below where it is expected, 1 x padding outside containing grid.


The bug also happens if the grid is inside a flex container, but not if its in a flow container.
Comment 1 Johannes Odland 2022-10-13 04:02:33 PDT
Created attachment 462957 [details]
Screenshot in Chrome
Comment 2 Karl Dubost 2022-10-13 19:03:44 PDT
Johannes, Thanks for the report.
Can you reproduce in STP 155?
https://developer.apple.com/safari/technology-preview/

It is working for me in STP 155.
Comment 3 Johannes Odland 2022-10-13 22:24:43 PDT
It works fine in TP 155. My bad, I should have checked there first. 

Do you know when the next release is due?
Comment 4 Radar WebKit Bug Importer 2022-10-20 04:02:20 PDT
<rdar://problem/101376382>