Repository navigation
Make layoutChanged only dispatch its event - #4509
Merged
Merged
Conversation
Before Leaf travels to a target (a comment's anchor, a search hit, an
obligation), it reveals what holds it. It used to dispatch its own
`lf-reveal` event on every ancestor, with `{target, mayReveal, present,
replacedView}`, so a widget that folds content had to import a Leaf contract
to open for Leaf's travel, and separately listen for `beforematch` to open
for the browser's find. This is the next slice of #3833: `reveal()` now does
what the browser's find-in-page and fragment navigation do (the HTML
standard's ancestor revealing algorithm), so a widget written as plain HTML
opens for both.
## The contract
- `reveal()` walks the target's ancestors outside-in. It opens a closed
`<details>`, opens a closed popover (which the browser's find leaves shut),
and at an element `hidden="until-found"` fires `beforematch` and removes the
attribute, as the browser does. Checked in Chromium and Firefox:
`beforematch` bubbles and the browser removes `hidden` after it.
- `replacedView`, which makes travel place the target at once instead of
scrolling from the old view's offset, is derived: it is true when a sibling
of the revealed element became hidden during the dispatch, as a tab set
hides the panel it leaves. A disclosure that hides nothing scrolls as before.
- `present(promise)` is gone. `ready` joins the `updateComplete` of each Lit
element holding what was revealed, so a widget whose switch finishes later
extends its own `updateComplete`, the hook #3982 adopted for settling.
- `mayReveal` stays the caller's check between steps; no listener needed it,
since listeners now run synchronously.
## Widgets
- `lf-tabs`, `lf-deck`, `lf-trace-compare`, `lf-options-settled` already hid
with `hidden="until-found"` and listened for `beforematch`; their
`lf-reveal` listeners are deleted. A settled options group used to open on
any reveal passing through it; it now opens only for a target inside a
folded option, so travel to the group's own row, already shown, leaves it
shut.
- `lf-visual-review` hides an unchosen case with `hidden="until-found"` in
place of `aria-hidden`, and opens it on `beforematch`. Its cases share one
grid cell so choosing another moves no control, so its CSS keeps the box
laid out (`content-visibility: visible`) and hides it with `visibility`, as
before; the browser's find still skips it.
- `lf-gloss` lets reveal open its tip popover and pins it on `beforetoggle`
when anything but the gloss opened it.
- `lf-diff` hides a file the filter leaves out with `hidden="until-found"`
instead of a `display: none` class, and clears the filter on `beforematch`.
Behavior change: the browser's find now reaches text in a filtered-out file
and clears the filter, as `g v` already did.
- The thread transcript, which is runtime code, keeps folded messages
`hidden`: thread reading takes a message an until-found box would leave as
shown and would land on it rather than on its fold. It registers its fold's
opener with the runtime-internal `revealedBy`, which `reveal()` calls.
- `lf-suggestion` no longer forces an immediate margin update on reveal;
`test_the_obligation_walk_lands_on_a_suggestion_the_reveal_just_opened`
passes without it.
`module-scroll-and-motion.md` ("Travel and history") states the new contract,
and the `view-reveal-arrival` eval's rubric follows it. I didn't score the
reference change: it replaces an API description rather than rewording a rule.
## Protocol 32 → 33
A page vendored at 32 has `lf-visual-review`, `lf-gloss` and `lf-diff` modules
that wait for an `lf-reveal` event this runtime no longer sends, so travel into
a hidden case, tip or filtered file would stop opening it.
## Tests
- `pnpm run test:runtime` (682 pass) and `pnpm run build:browser`.
- 42 focused browser tests by node id over tabs, deck, trace comparison,
settled options, glosses, visual review, diff filtering and `g v`, thread
folds and summaries, obligation walks, Go-to and thread travel, plus the
visual-review journey and export tests (25).
- Tests that used `lf-reveal` as a hook to hold a reveal (`test_go_to`,
`test_obligation_walk`, `test_on_panel`, `test_code_review`) now hide a
holder with `hidden="until-found"` and hold its `updateComplete`.
- Selectors that read `.lf-vr-case[aria-hidden="false"]` or the
`lf-diff-filtered` class read `:not([hidden])` instead.
- `test_a_widget_first_paints_the_box_it_presents[diff-closing-a-panel]` and
`[diff-in-a-phone-column]` fail identically on main 37e9061.
Refs #3833
# Conflicts: # dist/kernel/kernel.json # dist/kernel/runtime/bundle-data.js
Nothing calls the LAYOUT event's detail.present, so the promise layoutChanged returned was always resolved and the callers that passed it along waited on nothing. It now dispatches and returns nothing. Part of #3833.
leaf-agent
reviewed
Oct 27, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The layout-completion regression still depends on the removed event hook; it needs to be revised with this API change.
test_a_tab_layout_completion_preserves_native_navigation tested a tab switch whose layout completion a listener held; a tab switch now completes in its own task, so that window no longer exists. The resume-writing and obligation-walk tests keep their landing assertions without the hold.
leaf-agent
approved these changes
Oct 27, 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.
layoutChanged(el)dispatchedLAYOUTwith adetail.present(promise)hook and returned the joined promise, so a caller could wait for listeners' asynchronous layout work. No listener in the tree callspresent, so the returned promise was always already resolved, and the callers that passed it along (lf-tabs' view switch, lf-deck's#show, lf-trace-compare's#draw, the merge film's repaint) waited on nothing. The last real consumer of a similar promise,lf-reveal'spresent, went with #4500.layoutChangednow only dispatches the event and returns nothing; those callers stop returning or collecting it, and lf-tabs' Back/Forward claim awaits its switch instead of chaining.thenon it.module-authoring.mdsays to calllayoutChangedrather than await it.No protocol bump: a module vendored earlier that awaits the result or collects it in
Promise.allkeeps working, and no bundled module calls.thenon it.Part of #3833, which asks that a widget import from Leaf only what no standard form expresses.
Three browser tests used
detail.presentto hold a tab switch's layout completion.test_a_tab_layout_completion_preserves_native_navigationis deleted, since a tab switch now completes in its own task and the window it tested no longer exists;test_resume_writing_reveals_page_editor_from_a_covering_panel_and_keeps_backandtest_an_obligation_walk_glides_within_a_view_and_opens_other_tabs_at_the_questionkeep their landing assertions without the hold.Tests:
pnpm run test:runtime(682),pnpm run check:browser, and 16 browser tests by node id over tab switching and history, the deck, trace comparison and travel into tabs and visual parts.