Skip to content

fix(studio): return focus after schedule edits and scope the filter shortcut - #2316

Merged
kantord merged 1 commit into
mainfrom
studio-followups/06-schedules-focus-shortcuts
Oct 15, 2026
Merged

kantord merged 1 commit into
mainfrom
studio-followups/06-schedules-focus-shortcuts

Conversation

@kantord

@kantord kantord commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Edit from a row menu lost focus to the body, the detail page never restored it, and / was swallowed in dialogs and in loading or empty states.

Part of #2303 ("Tiny follow-up fixes"); it does not close it. This is PR 6 of 14 in a stack of draft PRs, reviewed and merged in order.

What changed

  • A row's Edit passes its Actions button as the focus opener; the detail page adds closeEditor() (cancel and successful save) that refocuses the actions menu.
  • useShortcut(id, handler, enabled = true) skips registration when disabled; the workspace enables schedules.filter only for a supported, non-empty list.
  • useShortcutSuppression is used in ScheduleForm (mounted only while open) and for both pages' delete dialogs. The shared Dialog and AlertDialog primitives are untouched.

Behavior changes

Focus returns to the row's Actions button or the detail actions menu after the edit dialog closes. / is no longer prevented while loading, empty, or in a schedule dialog. Suppression also blocks other global shortcuts (mod+k, ?) while a schedule dialog is open, like the chat modals.

Screenshots

Before is the parent branch (#2315), after is this PR, with the same keyboard steps and offline mock data: open the actions menu from the keyboard, choose Edit, press Escape.

Scenario Before After
Edit from a row menu, then Escape
No focus ring anywhere (document.activeElement is BODY).

Focus ring on the row's Actions button (BUTTON, "Actions for daily-report").
Edit from the detail page, then Escape
No focus ring (BODY).

Focus ring on the Actions button ("Actions for daily-report").

The / fix has no screenshot pair: Radix keeps focus inside an open dialog even before the fix, so the search box never visibly takes focus. The tests assert that the keystroke is no longer claimed (defaultPrevented === false) while a schedule dialog is open and while the list is loading or empty.

Verification

Biome, typecheck, the full Studio test suite and pnpm generated:check pass on this branch, run on the assembled stack. The full Playwright suite passes on the stack tip (122 passed, 30 skipped, 0 failed, including chat-approval against a real mecated build). Six new tests fail without the fix. Two workspace dialog tests assert defaultPrevented === false on / with Cancel focused (a plain activeElement assertion was vacuous because Radix pulls focus into the dialog). The detail page has no / shortcut of its own, so its test registers a probe shortcut.

Not included

The BFF outcome change.

Fully or partially written by an AI agent.

🤖 Generated with Claude Code

@kantord
kantord added this pull request to stack #2325 October 14, 2026 13:27
@kantord kantord mentioned this pull request Oct 14, 2026
41 tasks done
@kantord
kantord marked this pull request as ready for review October 15, 2026 08:56

@peppescg peppescg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Daniel. Passing the trigger as the opener and gating the / registration on whether the search box is rendered are both clean fixes, and the defaultPrevented assertions are a good way around Radix's focus trap.

Nits:

  • apps/web/src/features/schedules/schedules-workspace.tsx:168: closeEditor focuses the opener without checking it's still in the DOM, so focus falls back to <body> when creating the first schedule from the empty state (the empty-state button unmounts), or when a save moves the row out of the active filter (e.g. enabling a schedule while "Paused" is selected). Fall back to the "Schedule task" button or the page heading when !editorOpener.current?.isConnected.

@kantord
kantord force-pushed the studio-followups/06-schedules-focus-shortcuts branch 4 times, most recently from 32425fc to 876ec2f Compare October 15, 2026 09:29
Base automatically changed from studio-followups/05-schedules-refresh to main October 15, 2026 12:25
…hortcut

Edit from a row menu now returns focus to the row's Actions button (the
menu item is gone), and the detail page returns it to its actions menu
after cancel or save. The schedule form and delete confirmations suppress
global shortcuts while open, and useShortcut takes an enabled flag so `/`
is not swallowed while the schedule list is loading or empty.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@kantord
kantord force-pushed the studio-followups/06-schedules-focus-shortcuts branch from 876ec2f to c9bc784 Compare October 15, 2026 12:25
@kantord
kantord merged commit bbd0958 into main Oct 15, 2026
53 of 55 checks passed
@kantord
kantord deleted the studio-followups/06-schedules-focus-shortcuts branch October 15, 2026 13:00
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 20, 2026
2 tasks
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.

2 participants