A nice focus trap :D

This commit is contained in:
Belen Curcio 2021-01-04 17:43:33 -03:00
parent 4f3ce796d1
commit 885a7ccdc1

View File

@ -16,12 +16,10 @@ interface Props {
onEnter?: () => void | null
}
// Todo: Drag focus to component
const Modal: FC<Props> = ({ children, open, onClose, onEnter = null }) => {
const ref = useRef() as React.MutableRefObject<HTMLDivElement>
const handleKey = (e: KeyboardEvent<HTMLDivElement>) => {
const handleKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
return onClose()
}