Skip to content

Commit 69df623

Browse files
AmirMohammad CheraghaliAmirMohammad Cheraghali
authored andcommitted
fix(help-guide): Add Escape key listener to close modal
1 parent dbfbf8b commit 69df623

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/components/HelpGuide.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ import { CircleHelp, X, MousePointer2, Search } from 'lucide-react';
44
export const HelpGuide: React.FC = () => {
55
const [isOpen, setIsOpen] = useState(false);
66

7+
React.useEffect(() => {
8+
const handleKeyDown = (e: KeyboardEvent) => {
9+
if (e.key === 'Escape' && isOpen) {
10+
setIsOpen(false);
11+
}
12+
};
13+
14+
window.addEventListener('keydown', handleKeyDown);
15+
return () => window.removeEventListener('keydown', handleKeyDown);
16+
}, [isOpen]);
17+
718
return (
819
<>
920
{/* Help Button */}

0 commit comments

Comments
 (0)