Skip to content

fix: let a focused box's own focus treatment outrank Leaf's focus mark - #5524

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-5478
Nov 5, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-5478

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Since #5306, a focused page control wears data-lf-mark="focus", and the mark rule in surfaces.css drew that as the box's own outline at !important. That overrode whatever the box said about its own focus, and broke two tests on main:

  • An author's #candidate-input:focus {outline: 4px solid violet} on a playground candidate read 2px (test_playground_controls_take_focus_from_editors_and_keep_candidate_focus).
  • The trace canvas is a ring overlay. It turns its outline off and rings itself with an inset ::after, because its viewport clips it flush. Under the mark it also drew an outline 3px outside, which the viewport cut (test_trace_pointer_annotation_stays_inside_the_panned_image_viewport).

Focus alone is the box's focus ring, not a comment's mark. It now draws at no weight, as the focus floor does, so the box's own focus treatment wins. Every other mark (aim, trace, a comment's mark, proxy and location rings, and focus combined with any of them) keeps its !important outline.

What changes on screen: a page control with an authored focus outline shows that outline again instead of Leaf's 2px ring, and a ring overlay's focus draws only its inset ring. leaf-dev stills for trace-image-keyboard, playground-text, playground-choice, gallery-tab-focus and proxy-drawing came out pixel-identical between base and head; the trace canvas's extra outline fell wholly outside its clipping viewport, so it was never visible.

What this gives up from #5306: #5306 made marks !important so that a page rule turning outlines off leaves the mark standing. For focus alone, a page's :focus {outline: none} on a commentable control now removes Leaf's focus cue there. That is how the focus floor already treats every other control. #5525 asks @max-sixty whether focus should keep that guarantee.

Verification: both tests fail on a6fefaa77 and pass with this change. These neighbouring ring and focus tests also pass: test_a_marked_scrolling_visual_keeps_its_keyboard_focus_ring, the ring-reading tests in controls/test_rings.py, two controls/test_focus.py tests, the mark-contour tests in test_render_anchors.py, and all of test_render_playwright_trace.py.

Closes #5478 — automated triage

Since #5306 a focused page control wears data-lf-mark="focus", and the
mark rule drew it as the box's own outline at !important. That took the
outline from whatever the box said about its focus: an author's
`#candidate-input:focus {outline: 4px ...}` read 2px, and the trace
canvas, a ring overlay that turns its outline off and rings itself with
an inset ::after because its viewport clips it flush, drew a second ring
3px outside that the viewport cut.

Focus alone is the box's focus ring, not a comment's mark, so it now
stands at no weight, as the focus floor does, and the box's own focus
treatment wins. Every other mark keeps its important outline, so a page
rule turning outlines off still leaves an aim, trace, comment mark,
proxy or location ring standing. Behavior changed: a page control's
authored focus outline shows again in place of Leaf's, and a ring
overlay's focus draws only its inset ring.

Closes #5478
@leaf-agent
leaf-agent merged commit 67ed4f9 into main Nov 5, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-5478 branch November 5, 2026 18:54
leaf-agent added a commit that referenced this pull request Nov 7, 2026
…ary test (#5668)

#5524 made focus alone (`data-lf-mark="focus"`) draw Leaf's ring at no
weight, so the box's own outline wins. Its comment in `surfaces.css`
says so: "the box's own focus treatment wins, an author's outline or a
carrier's". The `rounded` target in
`test_target_brackets_and_focus_share_the_visible_boundary` has an
authored `outline: 1px dashed`. After Escape it now shows that outline,
but the test still expected Leaf's solid 2px ring. That expectation came
from before #5524, so this updates it instead of rolling #5524 back.

**Behavior the test now protects:** focus alone on a box with an
authored outline shows the page's outline. The `square` target has no
outline of its own, and it still checks Leaf's focus ring, whole, on the
region's perimeter. The aim and a draft's mark still stand over the
page's outline on both targets, and the page's outline comes back once
no mark stands there.

**What stays open:** the fixture's dashed outline is decorative, not a
focus style. So on a box like this, keyboard focus no longer gets a ring
of its own. That follows from #5524's rule, which treats this the same
way the focus floor treats every other control. #5525 already asks
`max-sixty` whether focus should keep a ring the page can't remove. This
PR doesn't decide that, and if the answer is yes, this subtest's focus
step goes back to expecting the ring.

**Verification:** the test fails on main at `a54c1bcea` in its `rounded`
subtest (`'dashed' == 'solid'` at `test_render_aim.py:3658`) and passes
with this change. `ruff check` and `ruff format --check` are clean.

Closes #5647 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Nov 18, 2026
…ing on a commentable box (#6397)

Records #5525's decision in the header of
`browser/styles/components/surfaces.css`: on a commentable control,
focus alone stands at no weight, so a page's `:focus { outline: none }`
or decorative outline replaces Leaf's ring, as an author's outline
replaces the browser's own focus ring. The header now says the user
chose this and why the `!important` alternative fails (it overrides the
author's focus outline and a ring overlay's `outline: none`, drawing a
second ring outside the overlay's clipping box). This is a comment-only
change. The tests from #5524 and #5668 already expect this behavior.

Refs #5525

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.

Two focus-ring tests fail on main since #5306 drew every mark as the box's outline

1 participant