Skip to content

Commit

Permalink
fix: remove Drawer onClose
Browse files Browse the repository at this point in the history
  • Loading branch information
yougyung committed May 16, 2024
1 parent 2bc8fdb commit a2a861e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
9 changes: 1 addition & 8 deletions app/hooks/useDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ export default function useDialog(key: DialogKey, onClose?: () => void) {
setOpenDialogList([key, true]);
};

const close = () => {
const prevState = isOpenDialogList[key];
setOpenDialogList([key, false]);

if (prevState) onClose?.();
};

const toggle = () => {
const prevState = isOpenDialogList[key];
setOpenDialogList([key, !prevState]);

if (prevState) onClose?.();
};

return { isOpen, open, close, toggle };
return { isOpen, open, toggle };
}
6 changes: 3 additions & 3 deletions app/ui/view/molecule/drawer/drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ interface DrawerProps extends React.PropsWithChildren {
}

const Drawer = ({ children, drawerKey, onClose, className }: DrawerProps) => {
const { isOpen, close } = useDialog(drawerKey, onClose);
const { isOpen, toggle } = useDialog(drawerKey, onClose);

return (
<DrawerPrimitive.Root open={isOpen} onClose={close}>
<DrawerPrimitive.Root open={isOpen}>
<DrawerPrimitive.Portal>
<DrawerPrimitive.Overlay
onClick={close}
onClick={toggle}
className="fixed inset-0 z-50 bg-black/60"
data-testid="drawer-overlay"
/>
Expand Down

0 comments on commit a2a861e

Please sign in to comment.