mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(reply modal): close with escape key
This commit is contained in:
@@ -162,8 +162,19 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
|
||||
textRef.current.focus();
|
||||
}
|
||||
}, 0);
|
||||
|
||||
const handleEscape = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') {
|
||||
closeModal();
|
||||
}
|
||||
};
|
||||
document.addEventListener('keydown', handleEscape);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleEscape);
|
||||
};
|
||||
}
|
||||
}, [showReplyModal]);
|
||||
}, [showReplyModal, closeModal]);
|
||||
|
||||
useEffect(() => {
|
||||
if (textRef.current) {
|
||||
|
||||
Reference in New Issue
Block a user