The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 16:00 UTC
fix(web): Esc closes the theme editor, not Settings (#25130)
Co-authored-by: Aatman Jain <lives@MacBook-Pro.local> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Aatman Jain (AJ) committed
Nov 14, 2026 at 08:57 UTC
000d82dc67be2b0b1fcfe3edceeb6032b7e1e553
2 files changed
+65
apps/web/src/components/settings/ThemeEditorPanel.browser.test.tsx
+56
@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from "vite-plus/test";
2
import { page, userEvent } from "vite-plus/test/browser";
3
4
import { act, render } from "../../../test/render";
5
+import { Dialog, DialogPopup, DialogTitle } from "../ui/dialog";
6
import { ThemeEditorPanel } from "./ThemeEditorPanel";
7
8
function dragHeader(panel: HTMLElement, toX: number, toY: number) {
@@ -74,6 +75,41 @@ async function renderPanel() {
75
};
76
}
77
78
+// The editor floats beside the Settings dialog, whose Esc handler sits on the document.
79
+async function renderBesideSettings() {
80
+ const onSettingsOpenChange = vi.fn();
81
+ const onEditorOpenChange = vi.fn();
82
+ const screen = await render(
83
+ <>
84
+ <Dialog onOpenChange={onSettingsOpenChange} open>
85
+ <DialogPopup>
86
+ <DialogTitle>Settings</DialogTitle>
87
+ </DialogPopup>
88
+ </Dialog>
89
+ <ThemeEditorPanel
90
+ open
91
+ onOpenChange={onEditorOpenChange}
92
+ onSaved={() => true}
93
+ editingTheme={null}
94
+ initialAppearance="light"
95
+ restoreTheme={() => {}}
96
+ />
97
+ </>,
98
+ );
99
+ return {
100
+ onSettingsOpenChange,
101
+ onEditorOpenChange,
102
+ [Symbol.asyncDispose]: () => screen[Symbol.asyncDispose](),
103
+ };
104
+}
105
+
106
+// The modal Settings dialog marks the editor inert, hiding it from role queries and pointer input.
107
+async function editorElement(selector: string) {
108
+ const query = () => document.querySelector<HTMLElement>(`[data-theme-editor-panel] ${selector}`);
109
+ await expect.poll(query).toBeTruthy();
110
+ return query()!;
111
+}
112
+
113
describe("ThemeEditorPanel", () => {
114
it("keeps its left edge when resized after the window shrank", async () => {
115
await using view = await renderPanel();
@@ -148,4 +184,24 @@ describe("ThemeEditorPanel", () => {
184
});
185
expect((hex.element() as HTMLInputElement).value).toBe(original);
186
});
187
+
188
+ it("closes on Escape without closing Settings", async () => {
189
+ await using view = await renderBesideSettings();
190
+ (await editorElement("input")).focus();
191
+ await userEvent.keyboard("{Escape}");
192
+
193
+ expect(view.onEditorOpenChange).toHaveBeenCalledWith(false);
194
+ expect(view.onSettingsOpenChange).not.toHaveBeenCalled();
195
+ });
196
+
197
+ it("leaves inspection on Escape without closing the editor or Settings", async () => {
198
+ await using view = await renderBesideSettings();
199
+ (await editorElement('[aria-label="Inspect app colors"]')).click();
200
+ await editorElement('[aria-label="Cancel inspecting app colors"]');
201
+ await userEvent.keyboard("{Escape}");
202
+
203
+ await editorElement('[aria-label="Inspect app colors"]');
204
+ expect(view.onEditorOpenChange).not.toHaveBeenCalled();
205
+ expect(view.onSettingsOpenChange).not.toHaveBeenCalled();
206
+ });
207
});
apps/web/src/components/settings/ThemeEditorPanel.tsx
+9
@@ -692,7 +692,9 @@ export function ThemeEditorPanel({
692
};
693
const cancelInspection = (event: KeyboardEvent) => {
694
if (event.key !== "Escape") return;
695
+ // Esc leaves inspection only; Settings must not see it and close too.
696
event.preventDefault();
697
+ event.stopImmediatePropagation();
698
clearHover();
699
clearInspectorSelection();
700
};
@@ -1138,6 +1140,13 @@ export function ThemeEditorPanel({
1140
isMinimized && "max-h-none",
1141
)}
1142
data-theme-editor-panel
1143
+ onKeyDown={(event) => {
1144
+ // Popups opened from the editor are portaled outside it and handle their own Esc.
1145
+ if (event.key !== "Escape" || event.defaultPrevented) return;
1146
+ if (!event.currentTarget.contains(event.target as Node)) return;
1147
+ event.stopPropagation();
1148
+ onOpenChange(false);
1149
+ }}
1150
ref={panelRef}
1151
role="dialog"
1152
style={{