Fix dropdown and dialog key handling

This commit is contained in:
Gregory Schier
2023-04-01 21:04:39 -07:00
parent 4aa771ba29
commit ff3734d65a
3 changed files with 14 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ import classnames from 'classnames';
import { motion } from 'framer-motion';
import type { ReactNode } from 'react';
import { useMemo } from 'react';
import { useKeyPressEvent } from 'react-use';
import { Overlay } from '../Overlay';
import { Heading } from './Heading';
import { IconButton } from './IconButton';
@@ -33,6 +34,11 @@ export function Dialog({
[description],
);
useKeyPressEvent('Escape', (e) => {
e.preventDefault();
onClose();
});
return (
<Overlay open={open} onClose={onClose} portalName="dialog">
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">