Remove Escape from hotkeys

This commit is contained in:
Gregory Schier
2024-02-27 18:58:41 -08:00
parent c851dfe206
commit 63d7a44586
7 changed files with 52 additions and 26 deletions

View File

@@ -2,7 +2,7 @@ import classNames from 'classnames';
import { motion } from 'framer-motion';
import type { ReactNode } from 'react';
import { useMemo } from 'react';
import { useHotKey } from '../../hooks/useHotKey';
import { useKey } from 'react-use';
import { Overlay } from '../Overlay';
import { Heading } from './Heading';
import { IconButton } from './IconButton';
@@ -36,7 +36,15 @@ export function Dialog({
[description],
);
useHotKey('popup.close', onClose, { enable: open });
useKey(
'Escape',
() => {
if (!open) return;
onClose();
},
{},
[open],
);
return (
<Overlay open={open} onClose={onClose} portalName="dialog">