{
+ // 2. Rely on height transition end to safely unmount, instead of hardcoded fixed setTimeouts
+ if (toast.exiting && e.target === e.currentTarget && e.propertyName === 'height') {
+ removeToastCompletely(toast.id);
+ }
}}
- onMouseEnter={() => setIsHovered(true)}
- onMouseLeave={() => setIsHovered(false)}
- onFocus={() => setIsHovered(true)}
- onBlur={() => setIsHovered(false)}
>
-
{Icon}
-
{toast.message}
-
);
};
-const ToastContainer: React.FC<{ toasts: ToastState[]; removeToast: (id: string) => void }> = ({ toasts, removeToast }) => {
+const ToastContainer: React.FC<{ toasts: ToastState[]; removeToast: (id: string) => void; removeToastCompletely: (id: string) => void }> = ({ toasts, removeToast, removeToastCompletely }) => {
return (
-
-
+ // 3. Removed 'gap-3' to allow the dynamic mb-3 from the wrapper to handle spacing, allowing it to smoothly collapse
+
{toasts.map(toast => (
-
+
))}
);