Repository navigation
Conversation
There was a problem hiding this comment.
I recommend merging. I reproduced the stray ring on the base and it's gone with this change. The new "shows rings for keyboard navigation and operation only" test fails on the base (typing a key, then focus moved from code, draws a solid ring) and passes here. The screenshots show the same Button story after the same steps on the base and with this change. focus-ring.spec.ts and the focus/ring tests in composer.spec.ts pass (12), keyboard-mode-machine.test.ts passes (23), check-focus-rings.ts passes, and tsc is clean for ui and app. I also compiled the redefined Tailwind variant: focus-visible:, group-focus-visible:, peer-focus-visible: and group-has-[[data-focus-visible]] all produce the expected selectors.
Public API is unchanged. "Always show focus rings" is a client-side appearance setting stored by the app, not a config key.
No blocking concerns. One small gap for the follow-up: @pierre/trees keeps its own :focus-visible styles inside its shadow root, and the reset in base.css doesn't reach there. Those tree rows still follow Chromium's rule, as they did before this change.
|
Superseded by #65690, which removes the same stray rings with a much smaller change: no ring on scroll areas or on the composer, and the browser's rule left in place for every other control. |


Focus rings showed at random: around the whole timeline, around the composer after the app moved focus there, and still there after returning to the window. Rings now show only while the keyboard is moving through the app.
Before and after
Why the rings were random
:focus-visibleafter any key without Ctrl/Alt/Meta, typing included, until a mouse click moves focus to another element. Click in the timeline, press ↓ or PgDn, and the whole timeline rings.The rule
How
packages/ui/src/context/keyboard-mode-machine.tsis the pure transition.keyboard-mode.tsxfeeds it key, pointer and focus events and marks the focused element, through shadow roots, withdata-focus-visible.focus-visible:,group-focus-visible:andpeer-focus-visible:keep working, redefined in one line:base.cssremoves the browser's own ring, andbun run lintnow fails on a raw:focus-visible(script/check-focus-rings.ts).Why a mark on the element, not a flag on the root
Cost of one mode switch (the first Tab, or the first click after Tab), with the app's stylesheets in the session story:
<html>A root flag re-styles the whole page, because the base ring rule has no class or attribute to narrow it. The mark touches one element, and a mouse-only user never triggers a write.
Tests
focus-ring.spec.tsgains "shows rings for keyboard navigation and operation only", which fails on the old behaviour.keyboard-mode-machine.test.tsand the new story test prove.locator.focus()or a lone Shift to stand in for keyboard arrival press Tab first.Notes
field-focus.tsx,overlay-focus.tsx,dialog.tsxandfocus-rescue.tsxno longer affects what shows. Removing it is a follow-up.