Repository navigation
fix: fit the margin card's size outside box-motion's size delivery - #6727
Merged
Merged
Conversation
box-motion's shared observer asks the card's placement for a fit when a part of the card changes size, and the placement lands in that delivery. A fit that wrote the card's width or max-height there resized the aside that reading-regions and Floating UI also observe, so Firefox reported a ResizeObserver loop in the thread-panel gallery. A placement the delivery asks for now keeps the card's size and fits it again in the next frame. Closes #6604
leaf-agent
commented
Nov 22, 2026
leaf-agent
left a comment
Collaborator
Author
There was a problem hiding this comment.
The delivered-fit guard compares the rounded offsetWidth with the fractional room, so a delivered fit whose room moved by less than half a pixel from the last written width still writes width on #lf-margin-preview inside box-motion's delivery. That is the resize-in-delivery this PR moves out, only at sub-pixel scale. ResizeObserver reports fractional sizes, so the aside's other observers would miss it the same way. Comparing with the width the last fit wrote, at the precision layoutPx writes it, makes "leaves the card's width as it is" exact. I'll push this.
The rounded offsetWidth let a sub-pixel change of the room pass the guard, so a delivered fit could still write the card's width inside box-motion's size delivery.
This was referenced Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a part of the margin thread card changes size, box-motion's shared observer (
placedParts) asks the card's placement for a fit, and that placement lands in the observer's delivery. A fit that wrote the card'swidthormax-heightthere resized#lf-margin-preview. Reading-regions and Floating UI also observe that box, and it sits shallower than the parts being delivered, so Firefox reportedResizeObserver loop completed with undelivered notificationsin the thread-panel gallery. #6604 records the sequence. A placement the delivery asks for now leaves the card's width and cap as they are and schedules another fit for the next frame, which runs before layout and outside any delivery. Placements from every other path, such as opening, scrolling or a window resize, still write in place.The cost is at most one frame at the card's earlier size. That frame is still placed and followed by box-motion's tween, which then retargets to the new fit. Resting states don't change.
Verification, run locally on Linux:
uv run leaf-dev suite flake --copies 18 --workers 4 --load 8 'tests/journeys/test_render_gate.py::test_page_fixture_opens_without_firefox_console_warnings[thread-panel-gallery]': 3 of 12 copies errored with the loop on main (fac415460) and 18 of 18 passed with this change.tests/browser/margin/test_card_reply.py::test_a_card_a_scroll_moves_onto_or_off_the_windows_foot_as_it_resizes_only_resizes, passes in both browsers. So do the 113 card fit, growth and scroll tests selected fromtests/browser/margin,threads/test_layout.pyandthreads/test_arrivals.py.pnpm run check:frameworkandpnpm run test:runtimepass.The comment box beside a passage (
composing/floating-response.js) also gives box-motion a placement. Nothing has shown it resizing an observed box in the delivery, so it is unchanged here.Closes #6604 — automated triage