mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 08:54:13 +00:00
feat: close notepad on escape
This commit is contained in:
parent
60f167c4d7
commit
583578b315
1 changed files with 7 additions and 1 deletions
|
|
@ -39,6 +39,12 @@ export function Notepad({ onClose, show }: NotepadProps) {
|
|||
}
|
||||
}, [show]);
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
e.stopPropagation();
|
||||
|
||||
if (e.key === 'Escape') onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal show={show} wide onClose={onClose}>
|
||||
<header className={styles.header}>
|
||||
|
|
@ -71,7 +77,7 @@ export function Notepad({ onClose, show }: NotepadProps) {
|
|||
ref={textareaRef}
|
||||
value={note}
|
||||
onChange={e => write(e.target.value)}
|
||||
onKeyDown={e => e.stopPropagation()}
|
||||
onKeyDown={handleKeyDown}
|
||||
/>
|
||||
|
||||
<p className={styles.counter}>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue