Repository navigation
fix: preserve instant landings when a reading region opens - #4761
Merged
Merged
Conversation
Mark explicit instant landings as reader choices before scrolling, as smooth landings already are. This keeps reduced-motion trace Moments visible when opening the saved tree triggers continuity restoration. The scroll classifier introduced in #3772 otherwise reads that single jump during changed layout as layout-driven. Refs #4747
This was referenced Oct 30, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 5, 2026
…match (#5414) 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 Co-authored-by: leaf-agent <[email protected]>
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.
An instant landing on a saved trace element was missing the explicit scroll-choice marker used by smooth landings. When opening the tree also changed its layout, the scroll classifier introduced in #3772 treated that jump as layout's, so continuity restored the tree's older reading over the selected row. The shared landing function now marks both motions before scrolling. With reduced motion, the Saved element Moment keeps its row visible inside the tree and the page; ordinary motion and checkpoint reopening retain their behavior.
The existing reduced-motion regression fails on the base with the row at 784–840px outside a 228–408px band, and passes after this change. Both motion cases and checkpoint reopening pass, as do pane continuity in Chromium/WebKit, Firefox's native hidden-fold search, all 712 runtime tests, and
pnpm run check. Base/candidate startup probes load 40 requests (36 code requests) through upgrade and server-state presentation, with 28 fewer code bytes in the candidate.This is a partial repair.
test_trace_tree_opened_by_the_browser_keeps_its_matchstill fails on the base and candidate: it opens the disclosure and scrolls through a script in the same task. The classifier deliberately treats a single script jump coinciding with changed layout as layout's. That simulation does not establish actual browser-find behavior; Chromium and Firefoxwindow.findattempts did not open this trace disclosure. The remaining step is to reproduce through native find UI and establish the events it delivers before changing that classification. A full Chromium launch under Xvfb here fails before opening a page because its process-singleton socket is unavailable (Address family not supported by protocol); that check needs an environment supporting full Chromium's native window path. #4747 stays open for that work.Refs #4747 — automated triage