From cdcdd6a44f00c92a9cdadc9c9226f1254acbcd70 Mon Sep 17 00:00:00 2001 From: Eduard Gert Date: Wed, 10 Jun 2026 17:36:29 +0200 Subject: [PATCH] remove close animation from dialogs --- .../src/components/dialog/ConfirmModal.tsx | 68 +++++++------------ .../frontend/src/components/dialog/Dialog.tsx | 61 ++++++++++------- 2 files changed, 59 insertions(+), 70 deletions(-) diff --git a/client/ui/frontend/src/components/dialog/ConfirmModal.tsx b/client/ui/frontend/src/components/dialog/ConfirmModal.tsx index aa34b26b9..a13a473ce 100644 --- a/client/ui/frontend/src/components/dialog/ConfirmModal.tsx +++ b/client/ui/frontend/src/components/dialog/ConfirmModal.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useEffect, useState } from "react"; +import { ReactNode } from "react"; import { useTranslation } from "react-i18next"; import * as Dialog from "@/components/dialog/Dialog"; import { Button } from "@/components/buttons/Button"; @@ -30,22 +30,7 @@ export const ConfirmModal = ({ onCancel, }: ConfirmModalProps) => { const { t } = useTranslation(); - - // Retain last content so it survives Radix's close animation. - type Snapshot = Pick & { - cancelLabel: string; - }; - const [snapshot, setSnapshot] = useState(null); const resolvedCancel = cancelLabel ?? t("common.cancel"); - useEffect(() => { - if (open) { - setSnapshot({ title, description, confirmLabel, cancelLabel: resolvedCancel, danger }); - } - }, [open, title, description, confirmLabel, resolvedCancel, danger]); - - const view = open - ? { title, description, confirmLabel, cancelLabel: resolvedCancel, danger } - : snapshot; return ( e.preventDefault()} > - {view && ( -
-
- {view.title} - - {view.description} - -
- - - - - +
+
+ {title} + + {description} +
- )} + + + + + +
); diff --git a/client/ui/frontend/src/components/dialog/Dialog.tsx b/client/ui/frontend/src/components/dialog/Dialog.tsx index ff5159f45..fd1f80cd5 100644 --- a/client/ui/frontend/src/components/dialog/Dialog.tsx +++ b/client/ui/frontend/src/components/dialog/Dialog.tsx @@ -7,50 +7,61 @@ import { cn } from "@/lib/cn"; export const Root = DialogPrimitive.Root; -const Overlay = forwardRef< - ElementRef, - ComponentPropsWithoutRef ->(function DialogOverlay({ className, ...props }, ref) { - return ( - - ); -}); +type OverlayProps = ComponentPropsWithoutRef & { + exitAnimation?: boolean; +}; + +const Overlay = forwardRef, OverlayProps>( + function DialogOverlay({ className, exitAnimation = false, ...props }, ref) { + return ( + + ); + }, +); type ContentProps = ComponentPropsWithoutRef & { showClose?: boolean; maxWidthClass?: string; + exitAnimation?: boolean; }; export const Content = forwardRef, ContentProps>( function DialogContent( - { className, children, showClose = true, maxWidthClass = "max-w-md", ...props }, + { + className, + children, + showClose = true, + maxWidthClass = "max-w-md", + exitAnimation = false, + ...props + }, ref, ) { const { t } = useTranslation(); return ( - +