Bug 224424 - Grid element retains dimensions after its children are removed, children are not rendered anymore
Summary: Grid element retains dimensions after its children are removed, children are ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-12 02:04 PDT by Tomas Carnecky
Modified: 2021-04-19 02:05 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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>