Skip to content

Keep a focus ring's room at a bounded block's foot for controls inside Web Awesome - #5432

Merged
leaf-agent merged 2 commits into
mainfrom
grind/g-focus-ring
Nov 5, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
grind/g-focus-ring

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Tab onto a control at the foot or top of a bounded block now shows its whole focus ring, for a control that holds focus inside a Web Awesome control's own tree too: a diff's file filter, a package's wa-select or wa-slider, and a code block's Copy. Before this change, the filter, the select and the slider landed with the foot of their ring past the block's edge, and the block's "more below" fade lay over what was left.

This reduces #4125 to the case that remains, rings against a bounded block's side, which waits on a decision. notes/focus-ring-room.md now covers only that case.

The cause

Leaf's sheets read where focus is with selectors that don't reach into a shadow tree, in two kinds of rule:

  • The landing room. :where(:focus, [data-lf-focus]) gives the focused box scroll-margin: var(--focus-ring-landing), which the browser's focus reveal and Leaf's landing (landing-scroll.js) both read. A vendor control's focused node is in its own tree, where neither selector matches. The browser then revealed it flush with the block's edge, and the ring's room landed outside. Copy had its own scroll-margin rule on ::part(button) for this reason (Stand a code block's lone Copy on its top border, as a one-mark toolbar #3916).
  • The fades. A scroller that holds more than it shows fades its edge, and stops fading while focus is inside it, through :has([data-lf-focus]). :has() doesn't look into a shadow tree, so the block kept fading over the filter's ring. A table's row-name fade (reading.css) and a thread card's top fade (annotation-chrome.css) used the same check.

focus.js already marks the focus path on both sides of a shadow boundary: data-lf-focus-within on every ancestor, the host included, and lf-focus as a part name on a focused node that has a part. So the fix reads those marks:

  • The landing room also matches ::part(lf-focus) (surfaces.css), which weighs a pseudo-element where the rule it joins weighs nothing. Copy's own rule goes.
  • All three fades lift on [data-lf-focus-within] rather than :is([data-lf-focus], :has([data-lf-focus])). The comment on the row-name fade already says it goes as the mask does, and with a wa-select focused in a scrolled row-named table both now lift, where neither did on main.

The fades now lift for focus on any control inside a Leaf widget's shadow tree too, such as a diff's rows or file headers, as the rule's wording intends. On main a bounded block kept fading while a diff's file row held focus, in both engines; it now lifts, a visible change on those pages.

Neither adds a mechanism or a case. The note's second candidate also changed ringBox and had wa-input and wa-select declare --lf-wears-ring. Measured here, those add room only to the select (under a pixel without, 6.8px with), whose ring is already whole without them, and the declaration on wa-input would also claim the floating panel's search field, whose wrapper wears its ring. So they stay out.

Evidence

The note's six cases from 2026-10-25, rebuilt on this branch's base (1b3e077) in headless Chromium 156 and Firefox 157. "Room" is the space between the ring's outer edge and the clipping edge; negative is cut.

Case On main With this change
1. live-progress, the "Release notes" summary in the stuck track whole (3px) unchanged
2. A margin sidebar's link and summary no rule reads aside.sidebar now; a layout-track beside a column keeps whole rings (3px) unchanged
3. A diff's file filter, Tab from 3px past the foot −3.6 / −4.0 at the foot, under the fade +6.4 / +6.0, no fade
4. A wa-select, 3px past the foot −5.8 / −6.2 +0.2 / +0.8
5. Copy at a block's top whole (+7.6 / +8) through its own rule whole (+7.6 / +8) through the shared rule
6. A single-thumb wa-slider −5.0 / −5.4 at the foot +1.0 / +0.6

A sweep that brought each control in by Tab from 4px inside to 24px past each edge found no faded arrival, and no cut one at the top or foot beyond one Chromium reading of the slider at −0.02px, flush with the edge. The select and the slider keep under a pixel there, since their ring stands on a box beyond the focused node (the combobox, and the thumb 7px below the rail); the filter and Copy keep 6 to 8px. No bundled widget uses a wa-select or wa-slider.

The filter's and the select's rings are still cut 3px at each side, since they fill the block's width and the block has no inline room. A link that starts a line loses 5px at its start, and a summary 5px at each side. That is the case that remains, and the note holds its measurements, candidates and reproduction.

Tests

  • test_a_key_onto_a_control_at_a_scrollers_edge_shows_its_ring gains the diff's file filter in Chromium and Firefox, and now also asserts that the bounded block doesn't fade the arriving ring. Flipped back to main's sheets, it fails in both engines (room −0.6 and −1.0, faded). With main's landing rule alone it fails on the room, and with main's fade rule alone on the fade.
  • test_a_scrolling_table_keeps_its_row_names_in_view now focuses a control in a shadow tree in the scrolled table and asserts that the table's mask and the row-name fade both go, in both directions. It fails with the old check on the row-name fade.
  • Probes on the merge base and this tree, in Chromium and Firefox: a wa-select in a scrolled row-named table, a diff's file row in a bounded block, and a control in a shadow tree in a thread card's transcript. Each fade stays on the base and lifts here. On main the card's top fade stayed for every focused control in the transcript, an ordinary button included, not only one in a shadow tree (the cause, inferred from the selector and not traced, is a :has() nested in a :has() that never matched), and it now lifts for all of them with no scroll moved. No test holds the thread card's case.
  • Run here and passing: the edge test's other parameters and the scroll-box tests in test_focus.py; the fade tests in test_render_pages.py; Copy's tests in test_render_code_reading.py and test_render_anchors.py; the diff filter tests; the ring tests in test_rings.py; test_workspaces_and_bounds.py -k "bound or more" but one; tests/model/test_interact_layer.py; test_the_thread_card_opens_on_its_latest_message_under_its_own_name; pnpm run test:runtime.
  • Failing here and with main's sheets put back alike, with the same errors: four Web Awesome tests in test_lifecycle_and_controls.py (a querySelector on null, then the .library-select combobox never appears), test_workspace_end_room_stays_inside_the_last_reading_region[pane] (a key badge intercepts the click), and test_the_menu_s_search_finds_rows_threads_and_commands (an unchanged hidden write on .lf-fp-quick). I didn't look for their cause.

Not run: the corpus ring sweep (test_each_sampled_focus_ring_is_shown_whole_in_its_surface, journeys tier), leaf-dev stills across the catalogue, and WebKit.

Part of #4125

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 2 commits November 4, 2026 23:48
…e Web Awesome

Tab onto a control at the foot or top of a bounded block now shows its whole focus ring when the control holds focus inside a Web Awesome control's own tree: a diff's file filter, a package's wa-select or wa-slider, and a code block's Copy. Before, the filter, select and slider landed with the foot of their ring past the block's edge, under the block's "more below" fade.

Two rules read where focus is with selectors that stop at a shadow boundary. The landing room, `:where(:focus, [data-lf-focus])` in surfaces.css, now also matches `::part(lf-focus)`, the part name focus.js already gives a focused node in a shadow tree, so the browser's focus reveal and landing-scroll.js read the room there; Copy's own scroll-margin rule goes. The fade in controls.css lifted on `:has([data-lf-focus])`, which can't see into a shadow tree, and now lifts on `[data-lf-focus-within]`, which focus.js sets on every ancestor up through the host.

Measured in Chromium 156 and Firefox 157, Tab from 3px past the foot: the filter goes from -3.6/-4.0px of room to +6.4/+6.0, the select from -5.8/-6.2 to +0.2/+0.8, the slider from -5.0/-5.4 to +1.0/+0.6. test_a_key_onto_a_control_at_a_scrollers_edge_shows_its_ring gains the filter in both engines and asserts the block doesn't fade the ring; each of the two rules taken back alone fails it.

notes/focus-ring-room.md now covers the case that remains, a ring against a bounded block's side, with its measurements, three candidates and a reproduction.

Part of #4125

Co-Authored-By: Claude <[email protected]>
…n a shadow tree

Both fades read focus through `:has([data-lf-focus])`, which can't see into a shadow tree. With a wa-select focused in a scrolled row-named table, the previous commit lifted the table's mask and left the row-name fade over the columns, though that rule's comment says it goes as the mask does. A thread card's top fade had the same check. Both now read `[data-lf-focus-within]`, as the scroller's fade does.

Probed on the merge base and this tree in Chromium 156 and Firefox 157: the row-name fade with a wa-select focused in a scrolled table, and a card's top fade with a control in a shadow tree in its transcript, each stay on the base and lift here. test_a_scrolling_table_keeps_its_row_names_in_view now asserts the table's mask and the row-name fade both go, and fails with the old check.

Part of #4125

Co-Authored-By: Claude <[email protected]>
@leaf-agent
leaf-agent merged commit fffe30a into main Nov 5, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the grind/g-focus-ring branch November 5, 2026 09:28
leaf-agent added a commit that referenced this pull request Nov 5, 2026
…ow the window (#5496)

Since #5361, a diff file's Comment opens a floating comment box, not its
inline box at the end of the file, whenever the file's end is below the
window. #5361 replaced `seatFab`'s question "does a panel stand over
this seat?" (`underOccluder`) with "does the user see this seat?"
(`seenRect`). Its intent was one way to answer "is this in front of the
user", and its list of visible changes doesn't include comment boxes.
`seenRect` also cuts at the window's top and bottom, so a seat that is
only scrolled out of view now counts as unseen too. In `pr-walkthrough`,
once `]` opens a file's hunk, that file's thread outlet sits at y≈914 in
a 900px window. The inline seat is refused and the box opens floating.
That is the failure
`test_each_sampled_focus_ring_is_shown_whole_in_its_surface` reports
(`#pr-exact-patch .lf-diff-file-comment did not open an inline
response`).

`seatFab` now refuses a seat only where the chrome covers it (`covered`,
the same cover rule `seenRect` cuts with). A seat under the floating
panel's room still sends the box to its home, as #5361 intended. A seat
that is only scrolled away takes the box, and the field's focus scrolls
it into view, which is what happened before #5361. One behavior moves
further than a plain revert would: a seat the chrome covers *in part* is
now refused too, where `seenRect` accepted any visible part. A box whose
seat is half under the panel opens at its home rather than half hidden.
Seats inside the panel itself are unaffected, since `coverBoxes` skips
the cover that holds them.

On screen, in the new `leaf-dev stills --state diff-file-comment`
(pr-walkthrough's longest file opened beneath the window's top, then its
Comment pressed, 1440×900): on main the box opens floating over the
contents column, away from the file; with this change it opens in the
file's thread at the file's end, scrolled into view under the file's
pinned header.

| main | this PR |
| --- | --- |
| ![Before: the file's comment box floats over the contents
column](https://github.com/user-attachments/assets/44b62067-2651-4445-867e-bb358aeb4f87)
| ![After: the comment box opens inline at the end of the
file](https://github.com/user-attachments/assets/070d6a88-574e-4085-aae2-179bcaf84d7b)
|

Verification:
- New
`test_a_file_s_comment_opens_inline_where_the_file_ends_below_the_window`
(`tests/browser/widgets/test_diffs.py`): an 80-line file in a 1200×700
window. On main, no inline composer opens. With the change, the inline
composer opens, its field takes focus and is in the viewport.
- Ran the ring journey restricted to `pr-walkthrough`. On main it fails
with the reported assertion. With the change, every `pr-walkthrough`
scope opens its surface with no ring faults. The only remaining failure
is the check that other examples' scopes were reached, which the
one-page restriction drops.
- `pnpm run test:runtime` (816 pass) and `pnpm run check:framework`
pass. Three `tests/browser/test_render_diff_controls.py` tests
(`test_file_tree_lands_at_the_file_start_after_reading_down[document,pane]`,
`test_an_expanded_diff_file_can_retry_its_failed_chunk_in_place`) fail
the same way on unmodified main `018fc2587`, so this change doesn't
cause them.

This fixes the failure the issue currently reports. The earlier
scheduled runs' ring faults (`lf-ask.lf-projected-location` rings 5px
past the window, runs 41816958231 and 41622727492, both before #5361)
are a separate cause that #5432 bears on. So this PR refers to the issue
and doesn't close it.

Refs #5459 — automated triage

---------

Co-authored-by: leaf-agent <[email protected]>
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.

2 participants