vaul
vaul copied to clipboard
fix: `onOpenChange` getting called twice when user clicks outside of the drawer
Fixes: https://github.com/emilkowalski/vaul/issues/290
I tried to test as many possibilities as I could, and I couldn't find anything that breaks by deleting that line of code.
@phxgg is attempting to deploy a commit to the emil Team on Vercel.
A member of the Team first needs to authorize it.
You said on this comment https://github.com/emilkowalski/vaul/issues/290#issuecomment-2002150057 that it was fixed in #297
However, #298 reintroduces the issue. I guess this is by accident?
I have the same issue, so I had to create a quick hack around it. Hopefully this will get resolved soon
...
const [isFirstTimeOpened, setIsFirstTimeOpened] = useState(true);
...
const handleOnOpenChanges = useCallback(
(aVal: boolean) => {
if (isFirstTimeOpened) {
setIsFirstTimeOpened(false);
return;
}
....
}, [...]
);
...
return (
<Drawer
open={open}
onOpenChange={handleOnOpenChanges}
direction={isDesktop ? "right" : "bottom"}
>
...
</Drawer>
);
};
Good call! That callback doesn't belong there, since closeDrawer(), which is below it, calls it as well
Fixed in #408