Skip to content

Show focus on a live sample iframe - #3807

Merged
leaf-agent merged 1 commit into
mainfrom
fix/ci-40087560199-sample-focus
Oct 24, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/ci-40087560199-sample-focus

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Give a live sample iframe a visible focus ring when Tab enters it. The sandboxed iframe receives keyboard focus, but the browser does not match :focus or :focus-visible on its host in this case. Leaf's focus runtime already marks the host with data-lf-focus; the sample stylesheet now draws the ring from that mark.

The focused full-view sample Tab test failed without the style rule (outline-style: none) and passes with it. pnpm run check:browser and git diff --check pass. This addresses the unindicated sample frame found while investigating the October 24 nightly run; that run has other independent failures.

@leaf-agent
leaf-agent merged commit 01f35e2 into main Oct 24, 2026
4 checks passed
@leaf-agent
leaf-agent deleted the fix/ci-40087560199-sample-focus branch October 24, 2026 13:39
max-sixty added a commit that referenced this pull request Oct 25, 2026
A press into a live sample took the user's keys into the sample's page
and showed nothing, so there was no telling whether `c` would comment on
the page or on the sample. The containing page hears no focus event when
a press moves focus into a frame (Firefox fires none, Chromium only the
window's `blur`), so its current location never became the frame, and
#3807's ring drew only after a Tab. Leaving the frame by a press on the
page fires nothing in Firefox either.

**Mechanism.** The sample child already sends the parent a notice for
each input; it now names the input's type, and `sample.js` hands it to a
new `inputInFrame` in `focus.js`. A press there puts the user on the
frame as a Tab would, and `reconcile` now takes them off a frame when a
press on the page leaves focus nowhere. A key or press in the child also
counts as the user's latest input, which decides whether the frame is
focus-visible: a frame never matches `:focus-visible` on its host, so
`paintFocus` applies the platform's rule from the inputs.

**Cue.** While the frame holds the keys, the sample's gutter takes the
focus ring's colour, after a press or a Tab. The ring keeps its meaning
everywhere else in Leaf, the keyboard's position, so the frame wears it
only when focus-visible. Full view keeps the gutter (27px), since its
own buttons share the keys with the sample there. The user picked the
gutter from three candidates (a ring on any entry, a coloured frame
edge, the gutter). The gutter is a new kind of mark, a region saying it
holds the keys, which only a frame needs.

**Tests.** `test_the_gutter_shows_while_keys_go_to_the_sample` covers a
press in and out, a Tab in, a press inside, a Tab again and Shift+Tab
out. It fails without the child's report. The Full view Tab walk checks
the gutter beside the ring.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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.

1 participant