Skip to content

fix: open a sent comment's card where the box painted after a scroll in the same task - #6725

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-6591-stale-anchor-rect
Nov 22, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-6591-stale-anchor-rect

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

A comment sent with no frame drawn since a page scroll opened its thread card off by the scroll. Chrome reports a box placed with CSS anchor positioning at its pre-scroll client rectangle for up to two frames after a scroll, while it paints where the scroll carried it. Send reads the comment box's frame with getBoundingClientRect (fabFrameAt), so the card adopted the stale offset in initialHold and kept it until a later scroll re-placed it. In the seats test in test_pins.py, focusing the field scrolled the window 297 px, and the card stood wholly below it with Resolve at viewport ratio 0. That is the second failure mode #6591 tracks.

floatingPlacement gains lag(): how far the box's client rectangle stands from where its last placement stands it, measured at its held edges from the anchor's box read now. The anchor itself is not anchor-positioned, so its rectangle is current. fabFrameAt subtracts the lag from the bar, the field and the field outline the card grows out of. A box in the window's plane has no anchor and no lag.

Verification

  • New test_a_send_in_the_task_that_scrolls_the_page_opens_the_card_where_the_box_stood scrolls the page 120 px in the Enter keydown that sends. Without CPU throttling, it fails on main every time (the card opens at the box's pre-scroll top, 120 px low) and passes with the change. With the scroll set to 0 it passes on main, so the test isolates the scroll.
  • uv run leaf-dev suite flake tests/browser/margin/test_pins.py::test_a_pass_for_a_change_to_the_rows_seats_them_as_a_whole_pass_would --cpu-throttle 8: 3/18 copies failed on main with Resolve at viewport ratio 0, and 36/36 passed with the change.
  • Neighbouring Send-placement tests (18 selected), pnpm run test:runtime (1080) and pnpm run check:browser pass.

The thread card's grip drop (carry.dropped in thread-preview.js) also adopts a client rectangle, but that rectangle comes from a drag rather than from reading the box in the task that scrolled, so this change leaves it alone.

Closes #6591 — automated triage

…in the same task

Chrome reports a box placed with CSS anchor positioning at its pre-scroll
client rectangle for up to two frames after the page scrolls, while it
paints where the scroll carried it. Send read the comment box's frame with
getBoundingClientRect, so a send with no frame drawn since a scroll (as
focusing the field can cause) handed the card a frame off by the scroll,
and the card stood that far from its words until a later scroll re-placed
it. In test_pins' seats test the card stood wholly below the window.

floatingPlacement now reports how far the box's client rectangle stands
from where its last placement stands it, measured from the anchor's box
read now (`lag`), and the comment box's frame subtracts it.

The new send-placement test scrolls in the Enter keydown that sends, and
fails before this change (card 120 px off) and passes after. The seats
test failed 3/18 copies on main with --cpu-throttle 8 and passed 36/36
with the change.

Closes #6591
@leaf-agent
leaf-agent merged commit 9fb8bd4 into main Nov 22, 2026
7 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-6591-stale-anchor-rect branch November 22, 2026 07:18
leaf-agent added a commit that referenced this pull request Nov 22, 2026
…d's as painted

Restores #6725's scroll compensation and its regression test, which the
previous commit reverted, and keeps the handoff fix that revert bought.

`fabFrameAt`, which Send reads through the exported `frame`, still subtracts
`floatingPlacement.lag()`, so a comment sent in the task that scrolled the
page opens its card where the box paints
(test_a_send_in_the_task_that_scrolls_the_page_opens_the_card_where_the_box_stood).
The handoff in `placeFab`, where saved state moves the box's attachment from
quoted words to their subject, adopts the frame as its rectangles read: `lag`
measures from the anchor's box read now, which that saved state has just
moved, so it counted the move as a scroll and the open box jumped
(test_saved_widget_words_cannot_dismiss_an_unfinished_comment).

Refs #6734
leaf-agent added a commit that referenced this pull request Nov 22, 2026
…out the scroll lag (#6735)

Keeps #6725's scroll compensation for Send, and stops the open comment
box from jumping when saved state moves what it's attached to. That jump
turned `test_saved_widget_words_cannot_dismiss_an_unfinished_comment`
red on main for three of its cases (`widget`, `revision`,
`dragged-revision`) in [run
44999105534](https://github.com/max-sixty/leaf/actions/runs/44999105534).

#6725 added `floatingPlacement.lag()`, the comment box's client
rectangle minus where its last placement stands it, measured from the
anchor's box read now. `fabFrameAt` subtracts it so a Send in the task
that scrolled the page opens its card where the box paints. `fabFrameAt`
has a second caller, though: the handoff in `placeFab`, which adopts the
seated editor's frame when saved state moves the box's attachment from
quoted words to their subject. There the anchor moved because its
content changed, not because of a scroll, so `lag()` counted that move
as lag and the box jumped (247 px in the `widget` case) while the user
was writing.

**The change** (net against `main`, one file): the frame computation now
takes the lag to subtract. `fabFrameAt`, which Send reads through the
exported `frame`, still passes `lag()`. The handoff in `placeFab` passes
zero and adopts the frame as its rectangles read, as it did before
#6725. Both of #6725's behaviors and its regression test stay.

**Verification** on the head `cf813f0fa`:
- `test_saved_widget_words_cannot_dismiss_an_unfinished_comment` (all
six cases) and
`test_a_send_in_the_task_that_scrolls_the_page_opens_the_card_where_the_box_stood`
pass: 7 passed.
- With `fabFrameAt` also passing zero, the Send test fails with the card
120 px off, which is the injected scroll. So the test still guards the
Send path.
- `pnpm run check:browser` passes.

Closes #6591. The previous commit on this branch reopened it while the
branch reverted #6725; with #6725 kept, its second failure mode stays
fixed.

Refs #6734

---------

Co-authored-by: leaf-agent <[email protected]>
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.

test_a_pass_for_a_change_to_the_rows_seats_them_as_a_whole_pass_would: the margin preview's Resolve goes inert under the click since #6557

1 participant