Fix Esc to close

This commit is contained in:
Daniel Kluge 2022-02-05 00:11:59 +01:00
parent 2f5c7cde58
commit 65e290b160
3 changed files with 5 additions and 4 deletions

View File

@ -55,15 +55,16 @@ Last updated: ${lastUpdate} | <a href="https://git.c0ntroller.de/c0ntroller/fron
}, [projectData, visible]); }, [projectData, visible]);
const onEscClose = (e: React.KeyboardEvent) => { const onEscClose = (e: React.KeyboardEvent) => {
console.log(e);
if (e.key === "Escape") { if (e.key === "Escape") {
e.preventDefault(); //e.preventDefault();
setVisible(false); setVisible(false);
} }
}; };
if (!visible) return <></>; if (!visible) return <></>;
return <div className={styles.modal} onKeyDown={onEscClose}> return <div className={styles.modal}>
<div ref={containerRef} className={`${styles.modalContainer} asciidoc`}> <div ref={containerRef} className={`${styles.modalContainer} asciidoc`}>
</div> </div>
</div>; </div>;

View File

@ -21,7 +21,7 @@ const Home: NextPage = () => {
} }
}; };
return (<main onKeyDown={hideModalOnEsc}> return (<main onKeyDown={hideModalOnEsc} tabIndex={-1}>
<Head> <Head>
<title>c0ntroller.de</title> <title>c0ntroller.de</title>
</Head> </Head>

@ -1 +1 @@
Subproject commit ef76baafc9a7a3d857ccd5633af2c38debd29251 Subproject commit 0496a88b3610ce432d678bf6d2e418f72e537758