Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/src/components/settings/ThemeCssEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function ThemeCssEditor({
function handleKeyDown(event: KeyboardEvent<HTMLTextAreaElement>) {
if (event.nativeEvent.isComposing || event.ctrlKey || event.metaKey || event.altKey) return;
const editor = event.currentTarget;
if (event.key === "Escape") {
if (event.key === "Escape" && (tabIndents || event.repeat)) {
event.preventDefault();
event.stopPropagation();
setTabIndents(false);
Expand Down
32 changes: 32 additions & 0 deletions apps/web/src/components/settings/ThemeEditorPanel.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,36 @@ describe("ThemeEditorPanel", () => {
expect(view.onEditorOpenChange).not.toHaveBeenCalled();
expect(view.onSettingsOpenChange).not.toHaveBeenCalled();
});

it("closes on a second Escape from the Custom CSS editor without closing Settings", async () => {
await using view = await renderBesideSettings();
await editorElement("button[aria-expanded]");
const cssToggle = Array.from(
document.querySelectorAll<HTMLButtonElement>(
"[data-theme-editor-panel] button[aria-expanded]",
),
).find((button) => button.textContent?.includes("Custom CSS"));
expect(cssToggle).toBeDefined();
cssToggle!.click();

const editor = await editorElement('textarea[aria-label="Custom CSS"]');
editor.focus();
await userEvent.keyboard("{Escape}");
editor.dispatchEvent(
new KeyboardEvent("keydown", {
bubbles: true,
cancelable: true,
key: "Escape",
repeat: true,
}),
);

expect(view.onEditorOpenChange).not.toHaveBeenCalled();
expect(view.onSettingsOpenChange).not.toHaveBeenCalled();

await userEvent.keyboard("{Escape}");

expect(view.onEditorOpenChange).toHaveBeenCalledWith(false);
expect(view.onSettingsOpenChange).not.toHaveBeenCalled();
});
});
Loading