Repository navigation
Keep the thread panel from taking focus off the control that opened it - #141
Conversation
Raising the panel is not a request to leave the control that raised it. Both dialog.show() and dialog.showModal() run the dialog focusing steps, so the panel took focus off the toggle: the button kept aria-expanded with no ring on it, and the reader's next Space went to a control they never chose. syncPanelLayer already restored a focus it found inside the panel. Carry the one it finds outside too, so a panel that arrives beside the page leaves the reader where they were standing. A covering panel is a mode and still takes them in.
|
Dispatched for The residual is not fixed by this, and it is in the same test. On this branch at What I measured, and on which treeEvery row is a local run on this sandbox's Playwright,
The residual is timing-sensitive in the way Beside that, no new red from the change. On Two rows of #133's board have also moved on their own since the reading it was last given, both measured on |
|
#144 overlaps this one and should be resolved against it before either lands. It takes the same test, by removing the modality rather than working around it: This PR is the smaller change if the modal question is to stay open. Leaving it open leaves the other five red. |
) ## Problem `test_render_gate.py::test_example_renders[corpus]` has been red on every `ci` run since [26dbf42](26dbf42) "Add external link treatment", in both colour schemes, and it still reproduces deterministically on `1ca4f40` in 11 seconds. #132 diagnosed it as "a different finding, from 26dbf42's external-link treatment rather than from 335bf9a" and left it; no PR or issue owns it. ``` assert ['[light] <lf-tab id=corpus-pr-walkthrough> puts "opens in a new tab" under .lf-ui, where no comment can reach it', '[dark] ...same...'] == [] ``` The subject is not the example. `render_version` is the pass `version check --render` runs on an agent-authored page, so any page with a cross-origin link inside a widget now fails handover on a word the reader is never shown. [`unreachableWords`](https://github.com/max-sixty/leaf/blob/03b4a0b2776102041a2d48580046fbf03b5e3446/skills/leaf/scripts/leaf/render-checks/reachability.js#L208) walks every text node under a widget's `.lf-ui` and reports the ones no declaration claims. Its excuse list held `.lf-quiet` and nothing else. 26dbf42's `renderExternalLinks` writes a note beside each external link — `class="lf-ui lf-external-note"`, `hidden`, textContent "opens in a new tab" — as the `aria-describedby` target for the link, and the walk found it: not `data-lf-said`, not inside the link's own `CONTROL` box (a describedby target is referenced by id, so it sits beside the link rather than in it), not `.lf-quiet`. ## Solution Excuse `[hidden]` beside `.lf-quiet`, one line and its comment. The check's own opening sentence is "Words the page shows that no user can select", and a `[hidden]` subtree shows none. The note cannot simply become a `.lf-quiet` word instead — which would have been the tidier answer, since `quietWord` is the repo's one idiom for "a word for a reader listening, silent on screen". `renderExternalLinks` is enrolled on declared shadow roots as well as the document, and the note is placed inside whatever root its link stands in, while `.lf-quiet`'s clip is a rule in the document stylesheet that no shadow tree adopts (only `MARK_RULES` is adopted, in `shadow.js`). A `.lf-quiet` note in an `x-shadow` widget would render as visible text next to the link. `hidden` is the silence available in every root. `[hidden]` is safe for this reading to trust rather than a hole for hidden-but-revealable words: the browser removes the attribute when it reveals `hidden="until-found"` content, so a word the reader finds is a word this check sees again, at the moment it is on screen. The two sibling gate readings that ask what a box shows already spell the same pair — [`widgets.js`](https://github.com/max-sixty/leaf/blob/03b4a0b2776102041a2d48580046fbf03b5e3446/skills/leaf/scripts/leaf/render-checks/widgets.js#L146) and [`standalone.js`](https://github.com/max-sixty/leaf/blob/03b4a0b2776102041a2d48580046fbf03b5e3446/skills/leaf/scripts/leaf/render-checks/standalone.js#L34). No assertion is loosened and no runtime file is touched. `skills/leaf/CLAUDE.md`'s row for this gate already reads "**visible** page words remain in reachable flow". ## Testing - `test_example_renders[corpus]` and `test_example_renders[pr-walkthrough]` — pass with `--run-nightly`; the first fails on `origin/main` unchanged at the two findings above. - `test_render_reports_words_a_widget_puts_out_of_reach` gains the pair: the same `.lf-ui` note inside `lf-option` reports nothing when `hidden` and is still reported when shown. Bug-back: with the `[hidden]` excuse reverted, the hidden half fails with exactly the corpus's finding. - `uv run pytest tests` — 723 passed, 6 skipped, on this branch rebased onto `c7b3706`. - `uv run pytest tests/test_render_commands.py tests/test_render_gate.py --run-nightly` — 77 passed, 4 failed, and all four are in the failed run's own list and owned elsewhere: `test_the_render_gate_measures_sideways_room_at_the_root_scrollport`, `test_the_reader_draws_an_edge_to_the_width_they_want[comments]` and `test_a_window_with_no_room_for_a_chosen_width_does_not_un_choose_it[comments]` are #121's `-15`, and `test_a_reader_arrives_at_what_they_left_rather_than_watching_it_arrive` is the intermittent one #121 documents. - `node --check`, pinned `prettier --check`, `ruff check` and `ruff format --check` pass on the two touched files. `pre-commit` is not on this sandbox's PATH, so its remaining hooks went unrun here. The preview digest is unmoved: `capture_input_files()` hashes `examples/`, `skills/leaf/assets`, the selected packages and three site scripts, and `skills/leaf/scripts/` is in none of them. ## What this does not fix The failed run had 32 red. Everything else in it sits with an open PR or issue — #121, #132, #134, #136, #137, #138, #140, #141, and issues #133 and #139 — with two exceptions I did not reach: - `test_render_controls.py::test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus` reports one unlit ring, `version-diff (.lf-version-diff:is(:focus-visible, .lf-focus-visible))`. That control is inside the versions menu #137 is rewriting, so it is likely downstream of that branch rather than its own cause; I have not verified it against #137's tree. - `test_render_navigation.py::test_a_widget_that_renames_its_role_keeps_the_press_offer_gave_it` is the generic-press question #132 raised and deliberately left as a product decision. --- Automated fix for [failed run](https://github.com/max-sixty/leaf/actions/runs/33330752582) Co-authored-by: leaf-agent <[email protected]>
## Problem [335bf9a](335bf9a) made `.lf-panel` a `<dialog>` and `syncPanelLayer` raised it with `showModal()` whenever it covers the page. A modal dialog makes the rest of the document inert, and covering is the posture in which the page most needs to stay live — so the banner toggle that opened the panel stopped closing it, the decisions toggle beside it stopped switching workspace, and the strip of page still showing beside the sheet stopped answering a selection hint. Separately, both `show()` and `showModal()` run the browser's dialog focusing steps, so opening the panel took focus off the control that opened it. Those are the six unowned tests in #139. Five are the inertness; the sixth is the focus. ## Solution The panel is shown, never shown modally, at either posture, and the invoker gets its focus back. What modality was carrying is already owned elsewhere and stays: the covering sheet's root scroll lock is the stylesheet's `overflow-y: hidden` under `COVERING`, and Escape is the ladder's — `browserDismissesTopLayer` hands Escape to the platform only for layers the platform really owns, which the keyboard reference and the page map sheet still are. `skills/leaf/CLAUDE.md` already states the same reading from the other direction: `presentPage` demotes authored `showModal()` calls to non-modal dialogs precisely so a modal's top-layer inertness cannot disable the recovery chrome. That deletes rather than adds machinery: `panelModal`, `ignoreNextClose`, the close-and-reopen across the covering breakpoint, the `resize` and `change` re-syncs that existed only to switch modality, the `panelFocusTarget` wiring, and the `close` listener that only a native modal dismissal could reach. `syncPanelLayer` becomes `showPanelLayer`, called once from `setPanel` — still before `renderPanel`, for the reason #138 gave it. The one user-visible consequence is the scrim: a non-modal dialog paints no `::backdrop`, so the `.lf-panel::backdrop` rule goes with it. That reads as the point rather than a cost — a scrim over a page the reader can now press would be saying the opposite of what the page does. ## Which of the six this closes Measured on this branch, rebased on `main` at 0b7f148 (so #121, #138 and #141 are in the base). | test | | | --- | --- | | `test_selection_hints_do_not_name_page_content_behind_a_covering_panel` | green | | `test_workspaces_replace_each_other_instead_of_stacking[500]` | green | | `test_coarse_pointer_chrome_gives_its_compact_controls_humane_aims` | green | | `test_esc_hands_the_page_back_after_it_has_closed_the_last_panel` | green — already fixed on `main` by #141, kept green here | | `test_the_responsive_action_shelf_keeps_primary_actions_in_reach` | green | | `test_coarse_pointer_resize_reach_stays_reachable_without_trapping_scroll` | past its modal failure, red on one that is now `main`'s — see below | ## What this does not fix `test_coarse_pointer_resize_reach_stays_reachable_without_trapping_scroll` needed both this and #121, and with both it is still red — on a different, earlier failure that #121 brought and this change does not touch. Walking it forward, each row a local `-n0` run: | tree | first failure | | --- | --- | | `main` at 1ca4f40 (pre-#121) | line 1017, `.lf-decisions` click — `<dialog … class="lf-ui lf-panel open"> intercepts pointer events` | | 1ca4f40 + this | line 1077, `assert edge["left"] >= -0.1` → `-12` | | 1ca4f40 + #121 | line 1006, `wait_for_function` on `.lf-threads` `scrollTop` after a touch swipe | | `main` post-#121 | line 1006, same | | `main` at 0b7f148 + this | line 1006, same | Line 1006 is *earlier* than the failures the modal caused, so it was masked until #121 landed; it is green on 1ca4f40 and on 1ca4f40 + this. It belongs to #121's `overflow-y: scroll`, is live on `main` now, and needs its own fix. ## Relation to #141 #141 landed while this was being measured. It fixed the focus half by extending `syncPanelLayer`'s restore arm while keeping `showModal()`, so `test_esc_hands_the_page_back_after_it_has_closed_the_last_panel` is already green on `main`; this rebases onto it and replaces that arm rather than competing with it. With modality gone the restore has one case instead of four, and `focusEnteredLayer`, `panelFocusTarget` and `returning` all go with it. ## Testing <details><summary>Runs</summary> On `main` at 0b7f148: ``` uv run pytest tests -q 724 passed, 6 skipped uv run pytest --run-nightly -n2 <the six, 7 node ids> 6 passed, 1 failed ``` The one failure is the row above. Earlier, on the pre-rebase base (1ca4f40), the owning files ran `5 failed, 77 passed` for `test_render_controls.py` + `test_render_semantic_selection.py` and `2 failed, 45 passed` for `test_render_conversations.py`; every one of those seven reproduced identically on clean `main` — five of the reserved-gutter shape #121 has since taken, plus `test_a_settlement_in_a_reply_leaves_its_own_anchor_on_the_page` and `test_a_mark_in_the_layer_promises_no_press_the_layer_will_not_take`, which are unrelated and untouched here. No new test: the six already own the behaviour, and each names it in its own docstring. </details> <details><summary>The visual delta, measured rather than described</summary> Same fixture, same viewport, same state — `LONG_PAGE` at 700×900 with the Threads panel open, which is the covering posture. Panel geometry is identical across the two (`x=265 y=96 w=420 h=804`); `dialog:modal` reads `true` before and `false` after. Every pixel outside the panel changes, and only by the scrim coming off: ``` left-of-panel differing px: 238500 of 238500 (222,221,219) -> (250,249,246) panel-region differing px: 43380 of 391500 the banner band above the panel, same two colours ``` `(222,221,219)` is paper under `color-mix(in srgb, var(--ink) 12%, transparent)`; `(250,249,246)` is paper. The banner was inside the dimmed area too, which is the visible half of the bug: the chrome the reader closes the panel from was drawn as if it were unavailable, and it was. </details> --- Closes #139 Co-authored-by: leaf-agent <[email protected]>
Problem
cirun 33327519405 on e7299eb failed with 33 tests red. One of them istest_render_controls.py::test_esc_hands_the_page_back_after_it_has_closed_the_last_panel, which #133 lists among the unowned remainder ("eschandback"). It still reproduces deterministically onmainat 1ca4f40, in about 7 seconds.The test's first assertion after a pointer open is the one that fails: the panel is visible and the toggle is no longer focused.
syncPanelLayerraises the panel withpanel.show()beside the page andpanel.showModal()over it. Both run the dialog focusing steps, so the browser moves focus into the dialog whichever one is called — the panel takes the focus off whatever raised it. The function already knew to put focus back, but only for a focus it found inside the panel:activeisnullwhenever the reader was standing outside it, and the restore arm readsactive. So the pointer route lost the toggle, and what the test's docstring bills for lands: the button holdsaria-expandedwith no ring on it, and the reader's next Space is that button rather than the page's scroll — the panel they dismissed comes back and nothing says why.Solution
Carry the element that was standing outside the layer alongside the one found inside it, and restore that too when nothing else claims the focus. Beside the page a panel is a column that arrived, so the reader stays where they were; a covering panel is a mode and still takes them in, which is the existing
focusEnteredLayerarm and is unchanged. Body is not somewhere to put anyone back, so it is not carried.This is
syncPanelLayer's own restore, extended to the case it did not name — not a second focus policy beside it, and not a call at the press site, which would have to be repeated at every door the panel has.Scope
Not the other 32. Measured against the current tip, they are owned or out of reach here:
scrollbar-gutter: stableon the root scroller)test_example_renders[command-hub],test_example_renders[corpus]test_render_anchors.pyeschandbackI reached the version-menu focus break independently and had the same one-line fix (
versionBtn.focus()beforeshowPopover) before #137 appeared; #137 covers it and the two contracts around it, so nothing of it is here.How the split was measured
Each row is a local
-n0or-n3run on the named tree, not an inference from the failure text.main(26dbf42): 31 still failed. Applying Keep the root's bar standing rather than reserving a gutter it never draws in #121'schrome-style.jshunk alone took that to 23; adding Read the settled ask's disclosure keys from DISCLOSE, and repaint every disclosure row's shortcuts #132's branch took it to 20.chrome-layout.js, so its hunk was applied tomainon its own and theesctest re-run against it — still red. The two changes are in different functions (setPaneland theResizeObserverthere,syncPanelLayerhere) and do not overlap.-n3—test_render_navigation.py::test_a_label_press_keeps_the_controls_keyboard_standing,test_render_outbox.py::test_a_withdrawal_restores_what_still_stands_not_what_stood_then,test_render_startup.py::test_a_fast_first_replay_does_not_flash_the_waiting_surfaceandtest_render_controls.py::test_covering_panel_takes_the_page_scroll_with_it— each pass at-n0on both trees, or fail on both. None of them is this change.Testing
test_esc_hands_the_page_back_after_it_has_closed_the_last_panelis the regression: it asserts both halves the docstring names — the ring the pointer reader never asked for, and the Space that reopens what they just dismissed — and it goes from red to green here. No new test, because that one already owns the behaviour.Runs on this branch, against the same files on clean 1ca4f40
Every remaining failure above reproduces on clean
main;test_esc_hands_the_page_back_after_it_has_closed_the_last_panelis the only test whose result this change moves. Earlier on 26dbf42 the wider render set (anchors,gate,navigation,widgets,projection,startup,drafts,outbox,options,pages,aim,reactions,margin,semantic_selection,commands,export,site) ran the same way with the same result.Automated fix for failed run