mirror of
https://github.com/remvze/moodist.git
synced 2026-02-28 00:53:13 +08:00
feat: close notepad on escape
This commit is contained in:
@@ -39,6 +39,12 @@ export function Notepad({ onClose, show }: NotepadProps) {
|
|||||||
}
|
}
|
||||||
}, [show]);
|
}, [show]);
|
||||||
|
|
||||||
|
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
if (e.key === 'Escape') onClose();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal show={show} wide onClose={onClose}>
|
<Modal show={show} wide onClose={onClose}>
|
||||||
<header className={styles.header}>
|
<header className={styles.header}>
|
||||||
@@ -71,7 +77,7 @@ export function Notepad({ onClose, show }: NotepadProps) {
|
|||||||
ref={textareaRef}
|
ref={textareaRef}
|
||||||
value={note}
|
value={note}
|
||||||
onChange={e => write(e.target.value)}
|
onChange={e => write(e.target.value)}
|
||||||
onKeyDown={e => e.stopPropagation()}
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<p className={styles.counter}>
|
<p className={styles.counter}>
|
||||||
|
|||||||
Reference in New Issue
Block a user