Open arvinpoddar opened 6 months ago
I want to work on this
when a dialog opens
pointer-events: none;
is added to body and pointer-events: auto;
is added to dialog
As a workaround I added pointer-events: auto;
to the toaster
@giveerr I was trying to figure out how does the state management occurs under the hood. How did u figure it out. Plz share.
when a dialog opens
pointer-events: none;
is added to body andpointer-events: auto;
is added to dialogAs a workaround I added
pointer-events: auto;
to the toaster
This still doesn't prevent the dialog from closing when the toast is interacted with, right?
when a dialog opens
pointer-events: none;
is added to body andpointer-events: auto;
is added to dialog As a workaround I addedpointer-events: auto;
to the toasterThis still doesn't prevent the dialog from closing when the toast is interacted with, right?
The solution I found is this, there is already a discussion here about this
const handleClickOutside = useCallback((e: CustomEvent<{originalEvent: PointerEvent | FocusEvent }>) => {
const targetNode = document.querySelector('.toaster')
if (e.target && targetNode && targetNode?.contains(e.target as HTMLElement)) {
e.preventDefault()
}
}, [])
and add this to DialogContent
onPointerDownOutside={handleClickOutside}
onInteractOutside={handleClickOutside}
@giveerr the code u have given links to pertain to radix-ui source code. How do I incorporate it in shadCn.
I'm also having trouble to interact with Dropdown Menu button after open a Sonner Toast. It's like the button changes the clickable space after Sonner Toast appeared in top right position. I can click and close the toast without close the dialog, but my Dialog Trigger after this has much less space to click, like, i can only click if in the top right corner of the button used as Trigger.
Any updates on this bug fix?
Describe the bug
If you create a sonner from within any modalic element (dialog, context menu, dropdown, popover), any interaction with the resulting sonner toast will result in the modal element closing as well.
This issue was previously described in https://github.com/shadcn-ui/ui/issues/2401. However, increasing the
z-index
of the sonner group does not resolve the issue, and registering customonInteractOutside
handlers for every modalic component is an unwieldy option. Ideally, one should be able to interact with the sonners while a dialog is open without closing the dialog.Affected component/components
Sonner
How to reproduce
Codesandbox/StackBlitz link
https://codesandbox.io/p/devbox/shadcn-playground-forked-kxc7l8?file=/src/App.js:34,45&workspaceId=b7d16bab-058a-4b6f-b4f8-cb3182273009
Logs
No response
System Info
Before submitting