fix(app): keep composer focus rings unclipped and keyboard-only

The model trigger no longer takes focus on mouse press, so dialogs return focus to the prompt. Rings sit on the button edge with matching radius, the toolbar scroller is padded so rings aren't clipped, and a keyboard-opened model dialog returns focus to the trigger.
This commit is contained in:
Dax Raad
2026-10-19 10:56:30 -04:00
Unverified
parent 02fa73809f
commit 16a68872b3
4 changed files with 18 additions and 5 deletions
+6 -2
View File
@@ -371,13 +371,17 @@ test("keeps a narrow session composer contained when invoking a built-in", async
test("keeps focus in a dialog that replaces the model dialog and returns it to the composer caret", async ({
page,
}) => {
const { editor } = await openSession(page, { name: "ComposerDialogFocus", provider: NO_PROVIDER })
const { editor } = await openSession(page, {
name: "ComposerDialogFocus",
provider: provider({ id: "paid", name: "Paid", cost: { input: 1, output: 1 } }),
})
await editor.fill("keep me")
await editor.press("End")
await editor.press("ArrowLeft")
await editor.press("ArrowLeft")
await editor.press("ArrowLeft")
await editor.press("ControlOrMeta+'")
// Clicking the trigger leaves focus at the caret, so the replacing dialog returns it there.
await page.locator('[data-component="composer"] [data-action="composer-model"]').click()
const models = page.getByRole("dialog", { name: "Select model", exact: true })
await expect(models.getByRole("searchbox", { name: "Search models", exact: true })).toBeFocused()
+6 -2
View File
@@ -152,9 +152,13 @@ function ComposerModelControl(props: {
class="min-w-0 max-w-[60cqw] justify-start ![font-weight:440]"
classList={{ "animate-in fade-in": shouldAnimate() }}
style={{ height: "28px" }}
onClick={() => {
onMouseDown={(event: MouseEvent) => event.preventDefault()}
onClick={(event: MouseEvent) => {
if (!props.paid) return props.onUnpaidClick()
void dialog.show(() => <DialogSelectModel model={props.model} />, props.onClose)
// A pointer open keeps focus in the composer, so the dialog returns it to the caret. A keyboard open
// returns focus to this trigger instead of moving it to the editor.
const keyboard = document.activeElement === event.currentTarget
void dialog.show(() => <DialogSelectModel model={props.model} />, keyboard ? undefined : props.onClose)
}}
>
{content()}
@@ -25,6 +25,11 @@
);
}
/* The controls viewport scrolls and clips, so toolbar rings hug each control and fit inside its 2px inline padding. */
[data-component="composer"] :is([data-component="button-v2"], [data-component="icon-button-v2"]):is(:focus-visible, [data-state="focus"]) {
outline-offset: 0;
}
@media (hover: hover) {
[data-component="composer"]:not(:hover) .composer-variant-default:not(:focus-visible, [data-expanded]) {
opacity: 0;
+1 -1
View File
@@ -341,7 +341,7 @@ export function ComposerEditor(props: ComposerEditorProps) {
data-slot="composer-controls"
data-overflow-start={overflow.start}
data-overflow-end={overflow.end}
class="ms-1 me-3 h-full min-w-0 flex-1 overflow-x-auto overscroll-x-contain no-scrollbar"
class="ms-0.5 me-2.5 h-full min-w-0 flex-1 overflow-x-auto overscroll-x-contain px-0.5 no-scrollbar"
onScroll={updateOverflow}
aria-hidden={state.mode === "shell"}
inert={state.mode === "shell" ? true : undefined}