feat(reply modal): close with escape key

This commit is contained in:
Tom (plebeius.eth)
2025-01-30 22:05:05 +01:00
parent 87164fc800
commit 63cb5b6591
+12 -1
View File
@@ -162,8 +162,19 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
textRef.current.focus(); textRef.current.focus();
} }
}, 0); }, 0);
const handleEscape = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
closeModal();
}
};
document.addEventListener('keydown', handleEscape);
return () => {
document.removeEventListener('keydown', handleEscape);
};
} }
}, [showReplyModal]); }, [showReplyModal, closeModal]);
useEffect(() => { useEffect(() => {
if (textRef.current) { if (textRef.current) {