Skip to content
Open
Changes from 1 commit
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
20 changes: 19 additions & 1 deletion client-src/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,29 @@ const createOverlay = (options) => {
}, trustedTypesPolicyName);
}

let handleEscapeKey;

const hideOverlayWithEscCleanup = () => {
window.removeEventListener("keydown", handleEscapeKey);
hide();
};

const overlayService = createOverlayMachine({
showOverlay: ({ level = "error", messages, messageSource }) =>
show(level, messages, options.trustedTypesPolicyName, messageSource),
hideOverlay: hide,
hideOverlay: hideOverlayWithEscCleanup,
});
/**
* ESC key press to dismiss the overlay.
* @param {KeyboardEvent} event Keydown event
*/
handleEscapeKey = (event) => {
if (event.key === "Escape" || event.key === "Esc" || event.keyCode === 27) {
overlayService.send({ type: "DISMISS" });
}
};

window.addEventListener("keydown", handleEscapeKey);

if (options.catchRuntimeError) {
/**
Expand Down