feat: focus & keyboard navigation improvements [INS-2552]#10049
Open
pavkout wants to merge 4 commits into
Open
feat: focus & keyboard navigation improvements [INS-2552]#10049pavkout wants to merge 4 commits into
pavkout wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves keyboard-driven workflows across the Insomnia UI by adding consistent autofocus behavior to common “create/edit” flows and enabling Left/Right arrow expand/collapse in the project navigation sidebar, reducing reliance on mouse interactions.
Changes:
- Adds URL-bar autofocus for newly created requests via a one-shot in-memory focus signal.
- Adds
autoFocus/onAutoFocussupport toOneLineEditorand uses it to focus newly added KV rows / dialogs. - Adds sidebar Left/Right arrow handling for expand/collapse, updates Ctrl/Cmd+N parent selection behavior, and adds smoke-test coverage.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/insomnia/src/ui/components/sidebar/project-navigation-sidebar/project-navigation-sidebar.tsx | Adds Left/Right arrow key handling to expand/collapse focused tree rows. |
| packages/insomnia/src/ui/components/request-url-bar.tsx | Hooks URL bar autofocus to the new-request focus signal. |
| packages/insomnia/src/ui/components/request-url-bar-focus.ts | Introduces a module-level one-shot focus signal for newly created requests. |
| packages/insomnia/src/ui/components/modals/workspace-settings-modal.tsx | Autofocuses workspace name input when applicable. |
| packages/insomnia/src/ui/components/modals/request-settings-modal.tsx | Autofocuses request name input. |
| packages/insomnia/src/ui/components/modals/request-group-settings-modal.tsx | Autofocuses folder (request group) name input. |
| packages/insomnia/src/ui/components/key-value-editor/key-value-editor.tsx | Adds “focus new row name” behavior when adding KV pairs. |
| packages/insomnia/src/ui/components/editors/environment-key-value-editor/key-value-editor.tsx | Memoizes symmetric key and autofocuses trailing blank KV name on open. |
| packages/insomnia/src/ui/components/.client/codemirror/one-line-editor.tsx | Adds deferred autofocus support to CodeMirror-backed single-line editor. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.tsx | Updates Ctrl/Cmd+N parent selection logic to respect selected folder. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.request.new.tsx | Sets the URL-bar focus signal when creating URL-bar-backed request types. |
| packages/insomnia-smoke-test/tests/smoke/focus-and-keyboard.test.ts | Adds smoke tests covering focus rules and keyboard navigation behaviors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2a539c5 to
13072ea
Compare
Make common create/edit flows land the cursor where you'd start typing, and let the navigation sidebar expand/collapse folders with the arrow keys. - New request focuses the URL bar - Adding a query param / header focuses the new row's Name cell - Opening the KV environment editor focuses the trailing blank row's Name - Create/rename/settings dialogs focus the Name field - Sidebar Left/Right arrows collapse/expand the focused folder - Cmd/Ctrl-N creates the request inside the selected folder OneLineEditor gains autoFocus/onAutoFocus. The editor focus is deferred a frame so it wins against React Aria ListBox focus restoration, and the "new request" signal is module-level (read in render, cleared on focus) to stay correct under React StrictMode double-mounting. Adds focus-and-keyboard smoke tests to guard against regressions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-2552] The param/header/environment grids wrap their inputs in a React Aria ListBox, which restores DOM focus to the row right after the editor focuses itself. A single deferred focus won this race locally but lost on slower headless CI, so the grid/env focus smoke tests flaked. Re-assert focus across a short bounded window (rAF, up to 500ms), re-grabbing only when focus was bounced to a non-editable element (the row) and never when the user moved to another field, until the editor holds focus or the window elapses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…INS-2552] The previous module-level boolean was shared across every KeyValueEditor instance, so a concurrently mounting/remounting grid could consume it and focus an unrelated row. Store the specific new pair's id instead (it survives the async save and the remount) so only the newly added row can autofocus, and clear it once that exact row focuses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Keyboard-driven users had to keep reaching for the mouse: creating a request didn't focus the URL, opening param/header/environment grids didn't put the cursor in an input, and the sidebar couldn't expand/collapse folders with the arrow keys. This implements a set of focus/keyboard rules so that when you click to create/edit something with an obvious textbox, the cursor lands there and you can just start typing.
Changes
Implementation notes
OneLineEditorgainsautoFocus/onAutoFocusprops as a shared enabler.requestAnimationFrame) so it wins against React AriaListBoxfocus restoration, which otherwise yanks focus back to the row.Deliberate scope decisions
:idin the URL, so focusing the path-param value would yank the cursor out of the URL bar mid-type. Tab order already reaches it.Testing
focus-and-keyboard.test.tssmoke tests covering all of the above (7 tests, all green).npm run lint,npm run type-check, andnpm testall pass.