Skip to content

feat: focus & keyboard navigation improvements [INS-2552]#10049

Open
pavkout wants to merge 4 commits into
Kong:developfrom
pavkout:INS-2552
Open

feat: focus & keyboard navigation improvements [INS-2552]#10049
pavkout wants to merge 4 commits into
Kong:developfrom
pavkout:INS-2552

Conversation

@pavkout

@pavkout pavkout commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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

  • New request → URL bar focused (new requests only, not when opening existing ones)
  • Adding a query param / header → the new row's Name cell is focused
  • Opening the KV environment editor → the trailing blank row's Name is focused
  • Create / Rename / Settings dialogs → the Name field is focused (workspace, folder, request settings)
  • Sidebar Left/Right arrows → collapse/expand the focused folder (or project/workspace)
  • Cmd/Ctrl-N → creates the request inside the selected folder (was always workspace root when no request was active)

Implementation notes

  • OneLineEditor gains autoFocus / onAutoFocus props as a shared enabler.
  • Editor focus is deferred one frame (requestAnimationFrame) so it wins against React Aria ListBox focus restoration, which otherwise yanks focus back to the row.
  • The "focus URL on new request" signal is module-level (read during render, cleared once the editor focuses) so it stays correct under React StrictMode double-mounting — the router strips redirect search params, so that approach wasn't viable.

Deliberate scope decisions

  • Path params get no autofocus — you add them by typing :id in the URL, so focusing the path-param value would yank the cursor out of the URL bar mid-type. Tab order already reaches it.
  • Only HTTP / GraphQL / Event Stream / cURL URL bars are wired for new-request focus; WebSocket/gRPC use different panes and can follow up.

Testing

  • Adds focus-and-keyboard.test.ts smoke tests covering all of the above (7 tests, all green).
  • npm run lint, npm run type-check, and npm test all pass.

Copilot AI review requested due to automatic review settings June 9, 2026 11:18
@pavkout pavkout self-assigned this Jun 9, 2026
@pavkout pavkout requested a review from a team June 9, 2026 11:19

Copilot AI 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.

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 / onAutoFocus support to OneLineEditor and 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.

Comment thread packages/insomnia/src/ui/components/key-value-editor/key-value-editor.tsx Outdated
Comment thread packages/insomnia/src/ui/components/key-value-editor/key-value-editor.tsx Outdated
@pavkout pavkout force-pushed the INS-2552 branch 4 times, most recently from 2a539c5 to 13072ea Compare June 11, 2026 22:26
pavkout and others added 4 commits June 12, 2026 10:42
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>
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