chore: fix modal close on escape

This commit is contained in:
Aman Harwara
2023-05-19 19:11:13 +05:30
parent 8f2cdc5839
commit d83e371022
21 changed files with 45 additions and 64 deletions

View File

@@ -7,13 +7,19 @@ type Props = {
isOpen: boolean
children: ReactNode
animationVariant?: 'horizontal' | 'vertical'
close: () => void
}
const ModalOverlay = forwardRef(
({ isOpen, children, animationVariant, ...props }: Props, ref: ForwardedRef<HTMLDivElement>) => {
({ isOpen, children, animationVariant, close, ...props }: Props, ref: ForwardedRef<HTMLDivElement>) => {
const [isMounted, setElement] = useModalAnimation(isOpen, animationVariant)
const dialog = useDialogStore({
open: isMounted,
setOpen: (open) => {
if (!open) {
close()
}
},
})
if (!isMounted) {