mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 16:27:40 +00:00
fix: toast interaction with modal or drawer
This commit is contained in:
@@ -67,7 +67,8 @@ export const createNotification = (
|
|||||||
...toastProps,
|
...toastProps,
|
||||||
autoClose: toastProps.autoClose || 15000,
|
autoClose: toastProps.autoClose || 15000,
|
||||||
theme: "dark",
|
theme: "dark",
|
||||||
type: myProps?.type || "info"
|
type: myProps?.type || "info",
|
||||||
|
className: "pointer-events-auto"
|
||||||
});
|
});
|
||||||
|
|
||||||
export const NotificationContainer = () => (
|
export const NotificationContainer = () => (
|
||||||
|
|||||||
@@ -55,6 +55,19 @@ export const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
|
|||||||
{...props}
|
{...props}
|
||||||
ref={forwardedRef}
|
ref={forwardedRef}
|
||||||
className={twMerge(drawerContentVariation({ direction, className }))}
|
className={twMerge(drawerContentVariation({ direction, className }))}
|
||||||
|
onPointerDownOutside={(e) => {
|
||||||
|
const target = e.target as HTMLElement;
|
||||||
|
const toastElement = target.closest('[class*="Toastify"]');
|
||||||
|
if (toastElement) {
|
||||||
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onClose) {
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
props.onPointerDownOutside?.(e);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Card isRounded={false} className="dark h-full w-full">
|
<Card isRounded={false} className="dark h-full w-full">
|
||||||
{title && (
|
{title && (
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export type ModalContentProps = Omit<DialogPrimitive.DialogContentProps, "title"
|
|||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
overlayClassName?: string;
|
overlayClassName?: string;
|
||||||
showCloseButton?: boolean;
|
showCloseButton?: boolean;
|
||||||
|
closeOnOutsideClick?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(
|
export const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(
|
||||||
@@ -29,6 +30,7 @@ export const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(
|
|||||||
bodyClassName,
|
bodyClassName,
|
||||||
onClose,
|
onClose,
|
||||||
showCloseButton = true,
|
showCloseButton = true,
|
||||||
|
closeOnOutsideClick = true,
|
||||||
...props
|
...props
|
||||||
},
|
},
|
||||||
forwardedRef
|
forwardedRef
|
||||||
@@ -38,7 +40,23 @@ export const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(
|
|||||||
className={twMerge("animate-fade-in fixed inset-0 z-30 h-full w-full", overlayClassName)}
|
className={twMerge("animate-fade-in fixed inset-0 z-30 h-full w-full", overlayClassName)}
|
||||||
style={{ backgroundColor: "rgba(0, 0, 0, 0.7)" }}
|
style={{ backgroundColor: "rgba(0, 0, 0, 0.7)" }}
|
||||||
/>
|
/>
|
||||||
<DialogPrimitive.Content {...props} ref={forwardedRef}>
|
<DialogPrimitive.Content
|
||||||
|
{...props}
|
||||||
|
ref={forwardedRef}
|
||||||
|
onPointerDownOutside={(e) => {
|
||||||
|
const target = e.target as HTMLElement;
|
||||||
|
const toastElement = target.closest('[class*="Toastify"]');
|
||||||
|
if (toastElement) {
|
||||||
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (closeOnOutsideClick && onClose) {
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
props.onPointerDownOutside?.(e);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Card
|
<Card
|
||||||
isRounded
|
isRounded
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
|
|||||||
Reference in New Issue
Block a user