mirror of
https://github.com/wavetermdev/waveterm
synced 2026-05-22 16:28:32 +00:00
Close open modals on escape keydown (#1809)
This commit is contained in:
parent
19634ed5df
commit
2304b8be22
1 changed files with 11 additions and 1 deletions
|
|
@ -22,6 +22,7 @@ import { getLayoutModelForStaticTab } from "@/layout/lib/layoutModelHooks";
|
|||
import * as keyutil from "@/util/keyutil";
|
||||
import { fireAndForget } from "@/util/util";
|
||||
import * as jotai from "jotai";
|
||||
import { modalsModel } from "./modalmodel";
|
||||
|
||||
const simpleControlShiftAtom = jotai.atom(false);
|
||||
const globalKeyMap = new Map<string, (waveEvent: WaveKeyboardEvent) => boolean>();
|
||||
|
|
@ -384,7 +385,16 @@ function registerGlobalKeys() {
|
|||
return false;
|
||||
}
|
||||
globalKeyMap.set("Cmd:f", activateSearch);
|
||||
globalKeyMap.set("Escape", deactivateSearch);
|
||||
globalKeyMap.set("Escape", () => {
|
||||
if (modalsModel.hasOpenModals()) {
|
||||
modalsModel.popModal();
|
||||
return true;
|
||||
}
|
||||
if (deactivateSearch()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
const allKeys = Array.from(globalKeyMap.keys());
|
||||
// special case keys, handled by web view
|
||||
allKeys.push("Cmd:l", "Cmd:r", "Cmd:ArrowRight", "Cmd:ArrowLeft");
|
||||
|
|
|
|||
Loading…
Reference in a new issue