GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(ui): unify focus ring and add missing focus states by usrnk1 · Pull Request #64909 · anomalyco/opencode Conversation
|
| Before | After |
|---|---|
![]() |
![]() |
Keyboard focus on a Home recent session. Before: background only. After: the shared inset ring.
| Before | After |
|---|---|
![]() |
![]() |
Added by the opencode bot (AI-generated).
Fixes #56891
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ation Focus that falls to the page when its element is removed, disabled or stops being editable moves to the next item in its [data-focus-scope]. Consolidated sidebar, pinned groups, Recent, Inbox, tab groups and the mobile drawer draw the shared ring; accordion rows raise the focused header; settings layout cards show selection with a neutral border and a check.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The approach looks sound, but I couldn't verify it by hand. This is a web app/Desktop change, and the sandbox has no browser, so I couldn't run the component or e2e specs or take screenshots. With the PR, the ui, session-ui and app unit tests pass and ui and app type-check cleanly. Before/after recordings of the focus-rescue cases would help reviewers, for example closing a focused tab and deleting the last item in a list.
Public API: unchanged. The packages/gui-plugins edits are CSS and focus styling only; no exports or plugin interfaces change.
Concerns:
focus-rescue.tsx is installed app-wide, but nothing tests it directly. Its rules are subtle: next item, then previous, then widen to the enclosing scope, skip Kobalte tab lists, and defer to what had focus before an overlay. A small component test of those core cases would protect it (inline comment).focus-visibility.stories.tsx (+2.5k lines) is hand-built copies of app markup (palette, Home search, settings cards) styled with production CSS, and the new input-surfaces specs test those copies. They can pass while the real components drift. Where you can, point the specs at the real components, or trim the story to the cases the specs need.Fixes #56891
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| pending = setTimeout(rescue) | ||
| } | ||
|
|
||
| function rescue() { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This runs app-wide on every focus loss inside a [data-focus-scope], and the rules are subtle: next item, then previous after the last, widen to the enclosing scope, skip [role="tablist"], and hand back to what had focus before an overlay. Nothing tests it directly; the stories only describe it. A small component test of the core cases would catch regressions here. For example: remove the focused middle item and focus goes to the next one; remove the last item and it goes to the previous one; empty a scope and focus goes back to its opener; nothing happens inside a Kobalte tab list.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Added in d91d708: packages/app/component-tests/focus-rescue.spec.ts with a plain-DOM fixture, so it tests only the rescue. It covers the cases you listed: removing the focused middle item moves focus to the next one (with the keyboard ring), removing the last moves it to the previous one, emptying a scope returns focus to what had it before, and focus never goes into a tab list. The tab-list case fails without the [role="tablist"] exclusion, and the spec passes 30 of 30 runs at --workers=2 --repeat-each=10.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I'm resolving this from my side. The fixture in focus-rescue.fixture.tsx covers the cases I asked for, and the assertions test the right things:
Two moves focus to Three and checks :focus-visible. Removing Three (now the last) then moves focus back to One.opener sits outside any scope, and toasts holds a single item, so pick returns null and rescue falls back to the newest usable entry without a spot. That path is the one in the code.strip is inside role="tablist", including Add tab. Without the exclusion, focus would land on Tab A. That fits what you saw when it failed without the filter.Not covered yet, if you want more later:
[data-focus-scope] still has items.focusVisible: false).I read the spec and fixture at pr/head and checked them against rescue/pick/within in focus-rescue.tsx. I didn't run the spec, because this workspace has no Playwright browsers installed. I didn't change anything in repo/. The bun.lock modification there isn't mine.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| would only be an invisible one. Screen readers can still reach it. */} | ||
| <button | ||
| type="button" | ||
| tabindex="-1" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
tabindex="-1" takes "Jump to latest" out of the tab order, and I couldn't find a shortcut that does the same thing. A keyboard user far up a long timeline would then have to Tab through every row to get back down. Could it stay in the tab order with a visible ring instead? The header overlay and the 5px clip margin may already keep it from being clipped.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agreed, fixed in 432f8b1. "Jump to latest" is back in the Tab order and draws the shared ring from base.css (I dropped the outline-none and tabindex="-1"). Its container is inert while the button is hidden, so it is never an invisible Tab stop. Checked in the web app: scrolled up a long session and pressed Tab from the control before it; it takes focus with a solid 2px ring at a 2px offset. session-timeline-accessibility.spec.ts (including "jump to latest is reachable only while it is shown") and timeline-geometry.spec.ts pass.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The fix in 432f8b1 is correct: the button is back in the Tab order, no longer has outline-none, so it uses the shared ring, and the inert container still keeps it out of reach while it's hidden (virtualizer.tsx:1154). That resolves my concern.
One gap is left. Activating the button with the keyboard probably drops focus to <body>, which is the bug this PR is meant to fix:
jump turns false, and the container becomes inert while the button still has focus. Chromium then drops focus to <body>.focus-rescue.tsx won't catch this:
childList (lines 74–79), so inert set on the parent <div> never fires lose().[data-focus-scope]. The data-focus-scope at line 1184 is a different element, so pick() returns undefined and rescue does nothing.expect(jump).not.toBeFocused(), which also passes when focus is on <body>.A small fix is to hand focus on yourself when the button had it:
onClick={(event) => { const focused = document.activeElement === event.currentTarget input.onResumeScroll(prefersReducedMotion() ? "auto" : "smooth") if (focused) /* composer input, or the last timeline row */ .focus({ focusVisible: true }) }}
I think the composer is the natural target, since after "Jump to latest" you're at the end of the session. The test could then assert where focus ends up, not just that it left the button.
I checked this by reading the commit, the spec and focus-rescue.tsx. I didn't run the e2e or try it in a browser. I made no changes to the checkout; the modified bun.lock there isn't from me, and I left it alone.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed in 29afe5b. A keyboard activation (event.detail === 0) now moves focus to the prompt, through the same focusPrompt the composer uses for quotes, so it gets the composer's keyboard ring. A pointer click is unchanged. The e2e "jump to latest is reachable only while it is shown" now also scrolls up again, presses Enter on the button, and asserts the prompt is focused. It fails without the change and passes 3 of 3 runs with it. In a child session there is no prompt, so focus still drops there.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The change in 29afe5b looks right, and I have nothing blocking.
event.detail === 0 covers Enter, Space and screen-reader activation, since all three send a synthetic click with detail 0. A pointer click keeps its current behaviour (virtualizer.tsx:1165-1170).composer.quote.focus is focusPrompt in region.tsx:372. It focuses the prompt and puts the caret back where it was, and nothing else, so the quote path doesn't add any side effects here. The activation was a key press, so field-focus.tsx should show the prompt's keyboard ring.focusComposer returns early when there's no promptRef, so focus drops to <body> there, as you said. It's a small edge case and fine to leave for this PR. If you want to close it later, a fallback such as focusing the scroller viewport (with tabindex="-1") would keep focus in the timeline.I checked this by reading the diff, region.tsx and the spec. I didn't run the e2e. I made no changes to the checkout.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Both earlier points are fixed. Focus rescue now has a small, clear component test of its core cases: next or previous item, back to the opener when a scope empties, and never into a tab list. "Jump to latest" is back in the Tab order with the shared focus ring. I checked the new commits with a type check only; there is no browser in the sandbox, so I couldn't run the new spec. Public API unchanged. Nothing new to raise.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
# Conflicts: # packages/app/src/new-session/view.tsx
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Both earlier threads (the focus-rescue test and "Jump to latest" in the Tab order) were already fixed in the previous push. The new commit moves focus to the prompt after a keyboard "Jump to latest". That looks sound and its e2e step is small and clear. The merge from dev kept this PR's focus-ring changes in the moved providers/connect/tip.tsx. I checked the new commits with a type check only; there is no browser in the sandbox. Public API unchanged. Nothing new to raise.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
#262) * fix(ui): one keyboard focus ring everywhere, inset where an edge clips Ports the ring half of anomalyco/opencode#64909 and #65084. - opencode_ui::focus holds the ring: 2 pt of border-focus, 2 pt out by default, 2 pt in (focus_inset) for full-width rows, tabs, scroll viewports and controls flush with a clipping edge. FocusExt makes each control's choice one call in its builder. - The view's default ring moves from 2.5 to 2 pt out (button.css, icon-button.css). - Dark themes ring in blue-400 (theme.json and themes.json regenerated from upstream), and the kit's controls take the app's border-focus in every theme. - Inset rings: titlebar buttons and plugin titlebar items (#65084), sidebar session rows, group headers and Show more, inbox cards and headers, Home's project and session rows and its scroll viewport, the timeline viewport, side panel tabs, the narrow tabs trigger and drawer, Connect's provider, account and model rows, the question dock's progress and 2 pt option ring, the Find bar's close button. - Send keeps the outside ring; the composer's toolbar keeps the inside one. - The session title is a button inside its heading, a Tab stop, and a rename hands focus back to it. * fix(ui): keep Home's row actions clear of the row's inset focus ring
…ing (#269) The rest of anomalyco/opencode#64909's rings, on screens that landed since #262. - Interface and Navigation mode cards: selection is a neutral 2 pt border-strong edge and a 16 pt check outside the corner, never the blue focus colour; unselected sketches at 45%; resting border border-muted (interface-mode.css). - Project colour swatches: the chosen one rings in border-inverse; focus is the shared outline. - Settings project rows: the open button covers the row, so its inset ring is the row's. - Sidebar pins, pin groups, Recent group headers and its view-options trigger: inset rings.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Dropdown UI elements in settings not highlighted with keyboard navigation
There was an error while loading. Please reload this page.