Skip to content

Count a disclosure opened without its summary's click as travel to a match - #5414

Merged
leaf-agent merged 1 commit into
mainfrom
fix/disclosure-find-travel
Nov 5, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/disclosure-find-travel

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

When something other than the reader's click opens a closed <details> and scrolls to a match inside it, Leaf now counts that scroll as the reader's choice. Find-in-page does this. Before, continuity read the scroll as a layout move and put the trace's Saved elements tree back where the reader had left it, so the found row ended up out of view. test_trace_tree_opened_by_the_browser_keeps_its_match failed on every run. On current main it fails with the row at 480–535px, outside the 12–111px band where the tree shows rows. With this change it passes.

Cause. scrolling.js treats a single scroll jump as layout's when the box's extent changed while it moved. It makes one exception: travel into hidden content. Find-in-page signals that travel with beforematch, but only for hidden="until-found" folds. When find opens a <details> (the HTML ancestor-revealing algorithm), no beforematch fires. Its toggle event arrives in a later task. So opening the trace tree and scrolling to the row in the same frame looked like a layout move. #4761 fixed the Moment landing by marking Leaf's own instant landings. This is the browser-driven half that #4761 left open.

Change. A disclosure that opens without a click on its summary now marks the same travel that beforematch marks, and for the same two frames. A reader opening it themselves clicks the summary first, and the click is dispatched before the toggle. The mark covers only the opened disclosure and the boxes inside it. Leaf opens disclosures itself too: carry.js carries one open across a revision while layout moves the page around it, and the page's own scroll should still count as layout's there. The scrolling.js header states the rule.

Test basis. As max-sixty decided in #4747, the repair is checked against the test's scripted find: the test opens the disclosure, then calls native scrollIntoView. It has not been checked against the browser's real find bar, which headless Chromium doesn't have.

Verification.

  • tests/browser/test_render_playwright_trace.py: both tree tests pass, including checkpoint reopening, which confirms that a summary click still restores the reader's place.
  • tests/journeys/…::test_trace_moment_lands_its_saved_element_over_the_trees_reading: both motion cases pass.
  • Neighbouring place-keeping tests pass: Firefox's closed-fold find, the dial's folds, closing a fold in the floating panel, and a let-go into a closed fold.
  • pnpm run test:runtime (812 tests) and pnpm run check pass.

The browser-startup path gains two document-level capture listeners and no requests.

Closes #4747

…match

Find-in-page opens a closed <details> onto its match without firing
beforematch, and its toggle follows in a later task, so a scroll to the
match in the same frame read as layout's and continuity returned the
trace's Saved elements tree to the reader's old place. A disclosure that
opens without a click on its summary now marks the same travel
beforematch does, for its own box and those inside it, which leaves
carry.js's reopening across a revision to layout.

Behavior changed: a scroll ending in such a disclosure within two frames
of its opening is the reader's choice, so test_trace_tree_opened_by_the_
browser_keeps_its_match keeps the found row shown.

Closes #4747
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.

Trace tree opening leaves the selected row outside its visible band

1 participant