-
-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controlled drawer with modal={false}
does not work because of bug in useControllableState
#492
Comments
Actually, I think the So I guess the handleChange function should not contain any code with side effects meaning the current logic would have to be moved to a useEffect 🤔 Edit: On first look using the upstream modal prop and removing all the hacks seems to work just fine (at least in my limited test case): https://github.com/skirsten/vaul/tree/no-hacks |
Running into an issue with this as well |
Currently I'm doing this as a workaround: <Drawer.Root
open={isOpen}
onOpenChange={(v) => {
setIsOpen(v)
document.body.style.pointerEvents = "auto"
}}
modal={false}
>
</Drawer.Root> It doesn't work reliably and feels like a hack to undo a hack. 🤷 Edit: body {
pointer-events: all !important;
} Not an ideal solution. |
this worked great! thank you! |
This took me a while to trace down, but basically a Drawer that is controlled and has modal false e.g.:
and open is set from somewhere outside, it does not get to this line to hack the pointerEvents:
vaul/src/index.tsx
Line 187 in 5041029
because if the prop changes it does not get to this line to call the handleChange function here:
vaul/src/use-controllable-state.ts
Line 50 in 5041029
So to conclude, under these circumstances it will not remove the
pointerEvents = "none"
😢Also I am curious why these awful hacks with the pointerEvents are necessary instead of just setting
modal={false}
on theDialogPrimitive.Root
? Maybe this would break something else?The text was updated successfully, but these errors were encountered: