mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-17 01:15:19 +00:00
fix(dialog-ux): prevent default Radix double event onInteractOutside
This commit is contained in:
@@ -73,8 +73,21 @@ const DialogContent = React.forwardRef<
|
|||||||
|
|
||||||
// Handle outside interactions properly with Command components
|
// Handle outside interactions properly with Command components
|
||||||
const handleInteractOutside = React.useCallback(
|
const handleInteractOutside = React.useCallback(
|
||||||
(_e: Event) => {
|
(event: Event | React.MouseEvent) => {
|
||||||
|
// Don't close when clicking inside popovers, dropdowns, or command components
|
||||||
|
const target = event.target as HTMLElement;
|
||||||
|
if (
|
||||||
|
target.closest("[data-radix-popper-content-wrapper]") ||
|
||||||
|
target.closest("[cmdk-root]") ||
|
||||||
|
target.closest("[data-radix-command-root]")
|
||||||
|
) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (onOpenChange) {
|
if (onOpenChange) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -95,7 +108,10 @@ const DialogContent = React.forwardRef<
|
|||||||
return (
|
return (
|
||||||
<DialogPortal>
|
<DialogPortal>
|
||||||
{/* Custom overlay for modal=false - no click handler to avoid Command conflicts */}
|
{/* Custom overlay for modal=false - no click handler to avoid Command conflicts */}
|
||||||
<div className="fixed inset-0 z-50 bg-black/80 pointer-events-auto data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" />
|
<div
|
||||||
|
className="fixed inset-0 z-50 bg-black/80 pointer-events-auto data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
|
||||||
|
onClick={handleInteractOutside}
|
||||||
|
/>
|
||||||
<DialogPrimitive.Content
|
<DialogPrimitive.Content
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
@@ -103,20 +119,7 @@ const DialogContent = React.forwardRef<
|
|||||||
"flex flex-col max-h-[90vh]",
|
"flex flex-col max-h-[90vh]",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
onInteractOutside={(e) => {
|
onInteractOutside={(event) => event.preventDefault()}
|
||||||
const target = e.target as HTMLElement;
|
|
||||||
// Don't close when clicking inside popovers, dropdowns, or command components
|
|
||||||
if (
|
|
||||||
target.closest("[data-radix-popper-content-wrapper]") ||
|
|
||||||
target.closest("[cmdk-root]") ||
|
|
||||||
target.closest("[data-radix-command-root]")
|
|
||||||
) {
|
|
||||||
e.preventDefault();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Use our custom handler for modal=false behavior
|
|
||||||
handleInteractOutside(e);
|
|
||||||
}}
|
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user