Skip to content
Snippets Groups Projects
Commit a0b0a558 authored by Jose Manuel Serrano Amaut's avatar Jose Manuel Serrano Amaut
Browse files

[FEAT]: Add onKeyPress listener in FullScreen component

parent ea102b25
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,19 @@ const FullScreen: React.FC<FullScreenProps> = (props: FullScreenProps) => {
e.stopPropagation();
onClose?.();
}
React.useEffect(() => {
const handleCloseEsc = (evt: KeyboardEvent) => {
if (evt.key === "Escape") onClose?.();
};
console.log("adding listener");
document.addEventListener("keydown", handleCloseEsc);
return () => {
console.log("removing listener");
document.removeEventListener("keydown", handleCloseEsc);
};
}, []);
return (
<div
......@@ -19,6 +32,9 @@ const FullScreen: React.FC<FullScreenProps> = (props: FullScreenProps) => {
open ? "fui-fullscreen-container show-fs" : "fui-fullscreen-container"
}
onClick={handleClose}
onKeyPress={(evt) => {
if (evt.key === "Escape") onClose?.();
}}
>
{open && (
<div
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment