Repository navigation
fix(web): Escape while recording a shortcut no longer closes Settings #27151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
maria-rcks
merged 2 commits into
pingdotgg:main
from
treiber:fix/keybinding-recorder-escape
Nov 1, 2026
+106
−12
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
apps/web/src/components/settings/KeybindingsSettings.browser.test.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import { describe, expect, it, vi } from "vite-plus/test"; | ||
| import { page, userEvent, type Locator } from "vite-plus/test/browser"; | ||
|
|
||
| import { render } from "../../../test/render"; | ||
|
|
||
| vi.mock(import("../../state/session"), async (original) => ({ | ||
| ...(await original()), | ||
| useEnvironmentScope: () => true, | ||
| useEnvironmentsWithScope: ((environments: ReadonlyArray<{ environmentId: string }>) => | ||
| new Set(environments.map(({ environmentId }) => environmentId))) as never, | ||
| readEnvironmentScope: () => true, | ||
| })); | ||
| vi.mock(import("../../state/use-atom-command"), async (original) => ({ | ||
| ...(await original()), | ||
| useAtomCommand: (() => vi.fn()) as never, | ||
| })); | ||
| vi.mock(import("./SettingsScopeContext"), async (original) => ({ | ||
| ...(await original()), | ||
| useSettingsScope: (() => { | ||
| const environment = { environmentId: "env", serverConfig: { keybindings: [] } }; | ||
| return { environment, connectedEnvironments: [environment] }; | ||
| }) as never, | ||
| })); | ||
|
|
||
| import { Dialog, DialogPopup, DialogTitle } from "../ui/dialog"; | ||
| import { KeybindingsSettingsPanel } from "./KeybindingsSettings"; | ||
|
|
||
| // The modal dialog's inert layer swallows pointer events in this harness, so drive the DOM. | ||
| async function activate(locator: Locator, action: "click" | "focus") { | ||
| await expect.element(locator).toBeVisible(); | ||
| (locator.element() as HTMLElement)[action](); | ||
| } | ||
|
|
||
| const existingField = page.getByRole("textbox", { name: "Keybinding for Sidebar: Toggle" }); | ||
| const existingPill = page.getByRole("button", { name: /^Edit shortcut for Sidebar: Toggle:/ }); | ||
| const newField = page.getByRole("textbox", { name: "Keybinding for new keybinding" }); | ||
|
|
||
| describe("Esc in a shortcut recorder", () => { | ||
| it.each<{ | ||
| name: string; | ||
| field: Locator; | ||
| open: () => Promise<void>; | ||
| expectReset: () => Promise<void>; | ||
| }>([ | ||
| { | ||
| name: "existing binding", | ||
| field: existingField, | ||
| open: () => activate(existingPill, "click"), | ||
| expectReset: async () => { | ||
| await expect.element(existingField).not.toBeInTheDocument(); | ||
| await expect.element(existingPill).toHaveFocus(); | ||
| await expect.element(page.getByRole("button", { name: "Save" })).not.toBeInTheDocument(); | ||
| }, | ||
| }, | ||
| { | ||
| name: "new binding", | ||
| field: newField, | ||
| open: async () => { | ||
| await activate(page.getByRole("button", { name: "Add keybinding" }), "click"); | ||
| await activate(newField, "focus"); | ||
| }, | ||
| expectReset: async () => { | ||
| await expect.element(newField).toHaveValue(""); | ||
| await expect.element(newField).toHaveAttribute("placeholder", "Unassigned"); | ||
| }, | ||
| }, | ||
| ])("leaves the $name field without closing Settings", async ({ field, open, expectReset }) => { | ||
| const onOpenChange = vi.fn(); | ||
| await using _screen = await render( | ||
| <Dialog open onOpenChange={onOpenChange}> | ||
| <DialogPopup> | ||
| <DialogTitle>Settings</DialogTitle> | ||
| <KeybindingsSettingsPanel /> | ||
| </DialogPopup> | ||
| </Dialog>, | ||
| ); | ||
|
|
||
| await open(); | ||
| await userEvent.keyboard("{Control>}k{/Control}"); | ||
| await expect.element(field).not.toHaveValue(""); | ||
| await userEvent.tab(); | ||
| await activate(field, "focus"); | ||
| await expect.element(field).toHaveAttribute("placeholder", "Press shortcut"); | ||
|
|
||
| await userEvent.keyboard("{Escape}"); | ||
|
|
||
| expect(onOpenChange).not.toHaveBeenCalled(); | ||
| expect(document.activeElement?.matches("[data-keybinding-capture]")).toBe(false); | ||
| await expectReset(); | ||
|
|
||
| await userEvent.keyboard("{Escape}"); | ||
| expect(onOpenChange).toHaveBeenCalledWith(false, expect.anything()); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.