mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(settings modal): close with escape key
This commit is contained in:
@@ -21,6 +21,19 @@ const SettingsModal = () => {
|
|||||||
navigate(newPath);
|
navigate(newPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleEscape = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
closeModal();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.addEventListener('keydown', handleEscape);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('keydown', handleEscape);
|
||||||
|
};
|
||||||
|
}, [closeModal]);
|
||||||
|
|
||||||
const [showInterfaceSettings, setShowInterfaceSettings] = useState(false);
|
const [showInterfaceSettings, setShowInterfaceSettings] = useState(false);
|
||||||
const [showAccountSettings, setShowAccountSettings] = useState(false);
|
const [showAccountSettings, setShowAccountSettings] = useState(false);
|
||||||
const [showAvatarSettings, setShowAvatarSettings] = useState(false);
|
const [showAvatarSettings, setShowAvatarSettings] = useState(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user