Skip to content

Commit 2304b8b

Browse files
authored
Close open modals on escape keydown (#1809)
1 parent 19634ed commit 2304b8b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

frontend/app/store/keymodel.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { getLayoutModelForStaticTab } from "@/layout/lib/layoutModelHooks";
2222
import * as keyutil from "@/util/keyutil";
2323
import { fireAndForget } from "@/util/util";
2424
import * as jotai from "jotai";
25+
import { modalsModel } from "./modalmodel";
2526

2627
const simpleControlShiftAtom = jotai.atom(false);
2728
const globalKeyMap = new Map<string, (waveEvent: WaveKeyboardEvent) => boolean>();
@@ -384,7 +385,16 @@ function registerGlobalKeys() {
384385
return false;
385386
}
386387
globalKeyMap.set("Cmd:f", activateSearch);
387-
globalKeyMap.set("Escape", deactivateSearch);
388+
globalKeyMap.set("Escape", () => {
389+
if (modalsModel.hasOpenModals()) {
390+
modalsModel.popModal();
391+
return true;
392+
}
393+
if (deactivateSearch()) {
394+
return true;
395+
}
396+
return false;
397+
});
388398
const allKeys = Array.from(globalKeyMap.keys());
389399
// special case keys, handled by web view
390400
allKeys.push("Cmd:l", "Cmd:r", "Cmd:ArrowRight", "Cmd:ArrowLeft");

0 commit comments

Comments
 (0)