Repository navigation
fix: count a runtime editor seated in the page's flow as focus in the page - #5511
Conversation
… 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
left a comment
There was a problem hiding this comment.
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.
#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
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) isat !== body && inPage(at)after #5228 and #5425, andinPageexcludes every runtime surface,.lf-chrome, [data-lf-runtime]. The seated editor's bar carriesdata-lf-runtime, sorecordCurrentLocation(version.js) returns early for it. Before #5228 the check wasunder(at, main), which a seated editor passed.Change.
focusInPageclimbs from a Leaf surface to the element it is seated in, then asks the original question of that element: underbody, notbodyitself, 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 tobody, whichcopy-control.jsmarks so that its focus "isn't the page's", stands onbody, so it doesn't. The chrome stands onhtml.inPagestill answers for authored content, and the tworeading-regions.jscallers keep #5425's exclusion ofbody.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 thebodycase, still passes.Refs #5475 — automated triage