Public: anyone can read this; the crew can change it.

small: the focus ring is one shape on every button, link and input, and design-lint fails on a control that removes it #16809

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Every button, link, input and summary now draws the same focus ring from one token, and design-lint fails on any rule that removes the outline without a replacement. I ran bun test test/design, test/themes.test.ts and test/print-style.test.ts, plus tsc, gate.ts --fix and design-lint, and all pass.

Notes

opened this

Every button, link, input and summary now draws the same focus ring from one token, and design-lint fails on any rule that removes the outline without a replacement. I ran bun test test/design, test/themes.test.ts and test/print-style.test.ts, plus tsc, gate.ts --fix and design-lint, and all pass. I did not look at the rings in a browser.

What changed

  • Token: --ring (2px solid var(--accent)) and --ring-offset are in src/web/style/base.ts. The global :focus-visible rule and every explicit ring in components.ts and content.ts now use them.
  • Inputs: .input, .color-field, .editor-wrap and .topbar-search used to show a 3px soft box-shadow glow. They now show the same outline as everything else. That is a visible change to those four controls.
  • Lint rule: a new src/design/ring.ts finds rules that set outline to none or 0 with no replacement. A replacement is a box-shadow or border-colour in the same rule. It can also be a rule that rings the same control through its container's :focus-within or through a child selector. The rule is wired into scripts/design-lint.ts as scanRing and runs with the other checks, with no baseline, so none is allowed. :not(:focus-visible) selectors are skipped.
  • Existing offenders: none fail the new rule. The three rules that remove an outline (.topbar-search input, textarea.editor, .chart a) already ring through a container or sibling rule. .topbar-search and .editor-wrap now draw the standard ring.
  • Docs and tests: docs/design/sections/2-tokens.md has a --ring row. test/design-lint-ring.test.ts covers the finding, the three kinds of replacement, and that the shipped sheets pass.

Contrast: I did not change colours. The ring uses --accent, and src/design/contrast.ts already holds the focus ring to at least 3:1 in every theme, so dark themes are covered. I did not render both themes to compare the rings by eye.

Left out

  • The forced-colors rules keep their own Highlight outlines.
  • The ring-replacement check is a heuristic. It looks for a related rule in the same sheet, not computed styles.
  • The gate wants a "Try:" line on a push, so one empty commit carries it.

Try it

  • Run bun scripts/design-lint.ts.
  • Add .x:focus-visible{outline:none} to a style file and design-lint names it.
  • Tab through any page and every control wears the same accent ring.

🤖 Generated with Claude Code

Closes #16313

Show 8 earlier items

7 earlier comments
commented

The new comment from @trevato is the same automated "look pages" note, now for commit 255a730. It says the rule is met because a commit names /. It asks for no change, so I made none and pushed nothing.

I disagree with treating it as feedback to act on. It reads as the gate reporting a pass.

If the gate should name other pages, tell me which. The branch's commits already carry Looks: lines for /, /docs and /explore.

commented

Still red on current main: a page does not word more bare 'No …' empty states than it is named for. Fix it and push.

commented

Two of the four failures were mine, and I fixed them and pushed. The other two pass locally and I changed nothing for them.

  • Focus-ring tests: test/notes-ceiling.test.ts and test/a11y-landmarks.test.ts still matched the old outline: 2px solid var(--accent). The ring is now var(--ring), so both now match outline: var(--ring). The tests were out of date, not the code. Both files, plus test/empty-words-all.test.ts, now pass locally (28 tests).
  • "No …" empty states: test/empty-words-all.test.ts passes locally. The branch's last commit (255a730) names the three pages that word their own empty state, and the check ran before that commit's effect showed. I didn't change it.
  • Layout of 2000 nodes: test/map-scale.test.ts passes locally (4 tests). It failed at 1.8 s against a timing budget, so I took it for a loaded-runner flake. If it fails again on this push, it needs a closer look.

I did not run the full suite. The forge's check does that on this push.

commented

I merged main into the branch and pushed it. The only conflict was in src/web/style/components.ts, around the focus rules for .why > summary and .holds summary.

Resolution: I kept this branch's var(--ring) and var(--ring-offset) on .why > summary:focus-visible. I took main's new .holds summary rules and .files-list rule, but wrote the .holds summary:focus-visible outline as var(--ring) too, instead of main's 2px solid var(--accent).

Checks: bun x tsc --noEmit and bun scripts/design-lint.ts came back clean. bun scripts/gate.ts --fix left nothing to commit, and the 117 tests under test/design*, including the ring test, pass. I did not run the full suite, since scripts/fast.ts couldn't narrow it; the forge runs the full check on this push.

Not changed: three other places on the branch still hold the old literal outline: src/web/style/content.ts:627, src/web/node_facts.ts:43 and src/web/space_client.ts:57. They are outside this merge and the ring test passes with them in place, so I left them alone.

commented

Still red on current main: a page that moved to the table is off the list of own words. Fix it and push.

commented

I fixed the failing check and pushed. test/empty-words-all.test.ts now passes locally, along with test/design-lint-ring.test.ts, tsc --noEmit and design-lint. gate.ts --fix changed nothing. I did not run the rest of the suite; the forge runs it on this push.

The earlier merge of main left three pages on the "own words" list that no longer have their own bare "No …" empty states. They are src/web/pages/app_flags.ts, src/web/pages/read-grants.ts and src/web/render/reg.ts. The test counts pages named on that list that no longer have such a state, so those three entries made it fail. I merged the latest main and deleted the three entries. The test was wrong, not the code.

The focus-ring change itself is untouched.

commented

All three items from the review are done and pushed. I ran only the design-lint, empty-words and unused-exports tests plus tsc --noEmit, and they pass. The forge runs the full check on this push. I did not click through focus on the preview.

1. One shape.

  • The five rules you listed (.dxf-view svg, .facts, .space-legend, .map-canvas, .feed > .card) now use var(--ring).
  • The three 1px --fg outlines on scroll regions (.diagram-scroll, .gj-table, .prose .table-scroll) moved to the token too, so scroll regions no longer have a different ring.
  • .facts summary had no :focus-visible in its selector, so it showed the outline all the time. I added it, which goes beyond what you listed.

2. The lint. src/design/ring.ts now reports any :focus-visible or :focus-within rule whose outline is not var(--ring). Forced-colours rules (system colours like Highlight) are exempt. test/design-lint-ring.test.ts has a case for each.

3. Cleanups.

  • --ring-offset-tight: 1px is a new token in base.ts, and the four 1px literals use it. The two forced-colours rules keep their literal 1px.
  • The stale "shadow" comment at content.ts:1168 now says outline.
  • The 2-tokens.md row is shortened and prettier-formatted.
  • The test imports readFileSync instead of using require.

The commit says No door: because this is CSS and a lint script only. Several outline-offset: -2px values (inset rings on rows and tabs) stay as literals, since they are a different geometry from the token.

gate.ts now reports one comment line over 100 columns in src/web/pages/map.ts. It is a note, not a failure, and I left it for the nightly rewrap.

[
  {"go": "/", "look": "Tab through the topbar, buttons, links and inputs", "expect": "every focus ring is the same 2px accent outline; the topbar search and editor sit it 1px off their border"},
  {"go": "/map", "look": "Tab to the map canvas", "expect": "the same 2px accent ring, drawn inside the canvas edge"},
  {"go": "/", "look": "Tab to a scrollable table or diagram", "expect": "the 2px accent ring, no thin foreground line"}
]
commented

One test failure was caused by this pull, and I fixed it and pushed. The other five I left alone and haven't re-run here.

What changed: test/map-keys-pan.test.ts ("the canvas has a visible focus ring of its own") looked for the old hand-written rule, outline: 2px solid var(--accent). This pull moved .map-canvas:focus-visible in src/web/pages/map.ts to the shared var(--ring), so the assertion was stale. I changed it to expect outline: var(--ring); outline-offset: -2px. The test was wrong, not the code. That file now passes (6 tests).

Not touched:

  • test/look-loopback-only.test.ts and test/talk-infra-says.test.ts are red on main too, so the check doesn't count them against this pull.
  • I did not look at the outbox, the 200 MB child-write test or the HEAD-on-every-GET-route test.
  • I only ran test/map-keys-pan.test.ts, not tsc or the design-lint.

To try it: bun test test/map-keys-pan.test.ts.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs