Bug 224424

Summary: Grid element retains dimensions after its children are removed, children are not rendered anymore
Product: WebKit Reporter: Tomas Carnecky <tomc>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bfulgham, jfernandez, rego, simon.fraser, svillar, webkit-bug-importer, zalan, zsun
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Tomas Carnecky 2021-04-12 02:04:47 PDT
I have a horizontally scrollable list of cards, and a toggle button which removes/adds the cards from the container. When the cards are removed, the container becomes an div with no children. On Safari, clicking the button to remove the cards removes the children, but the container retains its original dimensions. Furthermore, the label from the button disappears (possibly a completely unrelated bug).

A repro case is here: https://vvugb.csb.app. Click the button and observe how the container doesn't shrink vertically. The <hr> is placed after the container, so it should move up, but doesn't. Clicking the button again to show the cards doesn't work anymore, the cards are inserted into the DOM but not rendered.

You can see the code here: https://codesandbox.io/s/peaceful-morning-vvugb?file=/src/App.tsx.

A couple notes:

 - If I remove overflowX:auto from the container, the bug disappears.
 - If I remove the card with the longest name ({ name: "Excepteur sint occaecat cupidatat non proident" }), the bug disappears (possibly bug is present whenever the text wraps to multiple lines?)
 - Resizing the viewport fixes the bug temporarily (I guess because it triggers a layout/render of the whole viewport).
Comment 1 Simon Fraser (smfr) 2021-04-12 11:31:32 PDT
Does this happen when not using grid layout?
Comment 2 Tomas Carnecky 2021-04-13 08:30:11 PDT
@smfr, no, if I change display:grid to display:flex on line 15 (the display of the card container), then the bug disappears.
Comment 3 Radar WebKit Bug Importer 2021-04-19 02:05:13 PDT
<rdar://problem/76835522>