Skip to content

fix: count a runtime editor seated in the page's flow as focus in the page - #5511

Merged
leaf-agent merged 2 commits into
mainfrom
fix/issue-5475-focus
Nov 5, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
fix/issue-5475-focus

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Since #5228, focus in a comment editor seated in a widget's outlet no longer counts as focus in the page, so the version controller never records it as the user's place, and a resize leaves the editor scrolled out of view. On the visual review journey at a phone width, the page stayed at the top with the editor's field at y=1187.

Cause. focusInPage (browser/runtime/passages.js) is at !== body && inPage(at) after #5228 and #5425, and inPage excludes every runtime surface, .lf-chrome, [data-lf-runtime]. The seated editor's bar carries data-lf-runtime, so recordCurrentLocation (version.js) returns early for it. Before #5228 the check was under(at, main), which a seated editor passed.

Change. focusInPage climbs from a Leaf surface to the element it is seated in, then asks the original question of that element: under body, not body itself, and not a Leaf surface. A comment editor in a widget's outlet stands in the widget, so it counts. The hidden field Copy appends to body, which copy-control.js marks so that its focus "isn't the page's", stands on body, so it doesn't. The chrome stands on html. inPage still answers for authored content, and the two reading-regions.js callers keep #5425's exclusion of body.

Tests. tests/browser/test_render_visual_review_journey.py::test_visual_review_keeps_its_inline_comment_editor_in_view_after_phone_resize[600] and [760] failed on main and pass with the change. test_panes.py::test_a_wheel_or_a_press_on_words_gives_a_pane_the_reading_keys_and_the_walk, which #5425 added for the body case, still passes.

Refs #5475 — automated triage

… page

`focusInPage` became `at !== body && inPage(at)` with #5228 and #5425, and
`inPage` excludes every runtime surface (`.lf-chrome, [data-lf-runtime]`). A
comment editor seated in a widget's outlet carries `data-lf-runtime`, so
focus there no longer counted as standing in the page: `recordCurrentLocation`
skipped it, and a resize left the editor scrolled out of view.

Before #5228 the test was `under(at, main)`, which a seated editor passed.
`focusInPage` now asks whether focus is under `body` and outside the chrome
root, apart from `body` itself; `inPage` keeps answering for authored
content. Behavior restored: the visual review's inline comment editor stays
in view after a phone resize.

Refs #5475

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

focusInPage now counts focus on any data-lf-runtime node under body as focus in the page, not only one seated in authored content. The Copy fallback field in copy-control.js is appended straight to document.body and marked field.dataset.lfRuntime = "" with the comment "Leaf's own, wherever it stands, so the moment it holds focus isn't the page's". focusDestination(field, "return") publishes a current location, so recordCurrentLocation now records a page place, ranked as the reader's, every time Copy uses that path. When Copy is pressed in the panel, focus returns to the chrome and nothing records a newer place. A later resize can then restore that page place over the one the reader made in a pane, which is the problem #5425 fixed for focus on body. Since #5228 the chrome root stands after body, so !inChrome(at) excludes almost nothing here: the only .lf-chrome under body is the bootstrap recovery status.

The new comment already states the rule that avoids this: a runtime control "stands in the page where its seat does". Reading it literally means climbing out of the runtime surface to the element it is seated in and asking the old question of that element. A seated editor's seat is the widget, so it counts. The Copy field's seat is body, so it doesn't, and the chrome's seat is html. I'll push that change.

…level field stays out of the page

The first commit counted focus on any runtime surface under body as focus
in the page. That included the hidden field Copy appends to body, whose
focus then recorded a page place ranked as the reader's. focusInPage now
climbs from a Leaf surface to the element it is seated in and asks the
original question there: a seated comment editor stands in its widget,
Copy's field on the body, the chrome on html.
@leaf-agent
leaf-agent merged commit 73dfb73 into main Nov 5, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-5475-focus branch November 5, 2026 17:38
max-sixty added a commit that referenced this pull request Nov 8, 2026
#5425 landed the repair this branch sat on, so its focusInPage move and its
wheel test are main's now. passages.js takes main's focusInPage, which #5511
extended to Leaf surfaces seated in the page. reading-regions.js keeps this
branch's chosen region beside main's removal of the local focusInPage.
test_panes.py keeps #5512's resting-box test, the wheel test once, then this
branch's two tests.

Refs #4062
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.

1 participant