Repository navigation
Keep the margin preview in the room the page has beside the panel - #114
Conversation
|
Still failing on
The run's two |
|
Second defect in the same card, which this PR's placement fix leaves standing: a preview the keyboard raised is never taken down once the walk leaves it. The card's close and its actions are Tab stops of their own, so the marker's That is why the ring walk read it as a covering: the card was still up six stops later, when the walk had come round to the panel's find box. After this PR it stands over the page's own content instead of the panel's — quieter, and still there for the rest of the visit. Evidence, and the one-line fix with a test that fails on this branch's headProbing the design-mode walk on
preview.addEventListener("focusout", deferPreviewClose);A fast walk hides it, which is why a plain Tab-through test passes either way: Playwright crosses the whole card inside the 70ms hysteresis, so the marker's own deferred reading fires after focus is already out and closes it by luck. The reader's pace does not. Dwelling one beat on the close is what makes the test ask the question: def test_a_preview_the_keyboard_raised_comes_down_when_the_keyboard_leaves(
browser, serve
):
"""The card is a Tab stop of its own — its close and its actions are controls — so the
marker's blur is not the last word on whether the reader is still at the map. Watched
only there, a preview opened by Tab stayed up for the rest of the visit, over whatever
it had been placed against: the corpus ring walk found it standing on the threads
panel's find box, with the box's here ring under the card's close."""
page, errors = open_page(
browser, serve(DECISION_PAGE, events=[COMMENT_ON_DECISION])
)
marker = page.locator('.lf-margin-marker[data-lf-kinds="comment"]')
preview = page.locator(".lf-margin-preview")
marker.focus()
expect(preview).to_be_visible()
# Walking into the card is not leaving it, and the reader dwells there: the marker's
# own deferred reading resolves while they stand on the close, finds them still at the
# map, and leaves the card up. That dwell is what the walk is about — a walk that
# crosses the whole card inside the 70ms hysteresis is answered by the marker's blur
# and never asks the question this test asks.
page.keyboard.press("Tab")
expect(page.locator(".lf-margin-preview-close")).to_be_focused()
page.wait_for_timeout(200)
expect(preview).to_be_visible()
inside = "() => document.querySelector('.lf-margin-preview').contains(document.activeElement)"
for _ in range(8):
page.keyboard.press("Tab")
if not page.evaluate(inside):
break
assert not page.evaluate(inside), "the walk never left the preview"
expect(preview).to_be_hidden()
assert errors == []
page.close()Run here against this PR's head ( Left here rather than opened as a second PR, since it is the same file and the same region as this one. |
Problem
tests/test_render_controls.py::test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpusis red onmain— 33271145855 and again atfcf32c2in 33272278362 — with one fault over 402 stops:in design mode of gallery, the ring on input.lf-find-box "" is not all there: its top edge is under button.lf-btn.lf-margin-preview-close "×".placePreview(living-margin.js) measured its room againstinnerWidth. An open panel does not stand over the page — it takes its strip out of the body (body[data-lf-panel] { margin-right: var(--lf-panel-w) }, chrome-style.js) — so a card placed against the window reaches across the page's right edge and into the panel. The first thing it covers there is the narrowing box at the top of the thread list, and a preview the reader left open is clamped tominToponce its marker scrolls away, which is exactly the band that box sits in. Probing the walk ongallerywith the panel open: the preview stands at629,50 → 949,248while the page's room ends atx=780and the panel runs780 → 1200, so its×sits over the find box's ring at792,101 → 1056,132.ce73388's tab frame is what exposed it — it moved the marker that walk opens — but the placement is wrong on its own, and the ring walk is what reads it: a control whose ring the reader can only see half of.Solution
Take the room from the page's own box (
document.body.getBoundingClientRect().right) rather than from the window, for both the right-of-marker test and the final clamp. This is the side's version of the line two above it, which already bounds the card by the banner rather than by the top of the window. Where the panel covers the page instead of standing beside it, the preview is already closed and refused (changePosture, keyed on the same covering query), so the body's edge is the whole of the answer.The new test opens the panel, hovers the marker, and asserts the card stays clear of the panel's left edge and of the page's room; it fails on
main(the preview stands in the panel: {'x': 773, 'width': 320} against {'x': 780}).Testing
uv run pytest tests/test_render_controls.py::test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus tests/test_render_margin.py --run-nightly -n0— 14 passed. The ring test fails on this branch's base without the change (reproduced here first, and it passes atce73388^, which is how the exposing commit was identified).uv run pytest tests/test_render_aim.py --run-nightly— 27 passed (design-mode chrome).uv run pytest tests— 715 passed, 6 skipped.pre-commit run --files plugins/leaf/skills/leaf/assets/runtime/living-margin.js tests/test_render_margin.py— clean.The run's other failures are not in this PR: the two
test_example_renderstrapped-margin readings are #113, and the text-entry key and search-geometry reads were fixed onmainby3d04843andfcf32c2.Automated fix for failed run