Skip to content

Collapse: measure a flow-root content wrapper - #9

Merged
microbit-matt-hillsdon merged 1 commit into
mainfrom
collapse-margin-fix
Jul 30, 2026
Merged

Collapse: measure a flow-root content wrapper#9
microbit-matt-hillsdon merged 1 commit into
mainfrom
collapse-margin-fix

Conversation

@microbit-matt-hillsdon

Copy link
Copy Markdown
Contributor

Spotted reviewing Python Editor.

The measured inner div wasn't a block formatting context, so children's margins collapsed through it and scrollHeight under-measured; the outer overflow:hidden wrapper IS a BFC and lays the margins out inside itself, so the resting fixed height clipped the last line of margined content (python-editor's API docs: 63px measured vs 74px real - the content's first paragraph carries a 10.56px top margin). display: flow-root makes the measurement truthful; rendering is unchanged since the margins were always painted inside the outer BFC.

The measured inner div wasn't a block formatting context, so children's
margins collapsed through it and scrollHeight under-measured; the outer
overflow:hidden wrapper IS a BFC and lays the margins out inside
itself, so the resting fixed height clipped the last line of margined
content (python-editor's API docs: 63px measured vs 74px real -
the content's first paragraph carries a 10.56px top margin).
display: flow-root makes the measurement truthful; rendering is
unchanged since the margins were always painted inside the outer BFC.
@microbit-matt-hillsdon
microbit-matt-hillsdon merged commit 4ca924a into main Jul 30, 2026
1 check passed
@microbit-matt-hillsdon
microbit-matt-hillsdon deleted the collapse-margin-fix branch July 30, 2026 16:33
microbit-matt-hillsdon added a commit that referenced this pull request Aug 3, 2026
Two findings from classroom's leaf-primitive port.

#30: Chakra's reset carries normalize's `hr { box-sizing: content-box }` and
Panda's preflight sets border-box on everything with no `hr` exception, so an
`<hr>` with an explicit height plus top/bottom borders silently changes height
at the flip. The zero-size-hr double-edge trick (1px on all four sides of a
0-width hr, the side borders reading as one 2px rule) is exactly that shape and
was in three apps; Divider's `thickness` variant is height-stable instead.
classroom's logo divider was 35px rather than the 33px its code asked for, and
was the only pixel difference across five screens.

#9/#17: confirmed from the other direction that a literal utility-named prop
does survive a plain wrapper — `h={23}` extracted and emitted `height: 23px`,
matching Chakra's unitless-number handling exactly. So #9's real scope is
non-literal values and non-utility prop names, which is worth saying plainly
next to the wrapper advice it seemed to contradict.
microbit-matt-hillsdon added a commit that referenced this pull request Aug 3, 2026
Two findings from classroom's leaf-primitive port.

#30: Chakra's reset carries normalize's `hr { box-sizing: content-box }` and
Panda's preflight sets border-box on everything with no `hr` exception, so an
`<hr>` with an explicit height plus top/bottom borders silently changes height
at the flip. The zero-size-hr double-edge trick (1px on all four sides of a
0-width hr, the side borders reading as one 2px rule) is exactly that shape and
was in three apps; Divider's `thickness` variant is height-stable instead.
classroom's logo divider was 35px rather than the 33px its code asked for, and
was the only pixel difference across five screens.

#9/#17: confirmed from the other direction that a literal utility-named prop
does survive a plain wrapper — `h={23}` extracted and emitted `height: 23px`,
matching Chakra's unitless-number handling exactly. So #9's real scope is
non-literal values and non-utility prop names, which is worth saying plainly
next to the wrapper advice it seemed to contradict.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant