From 16db585022950d1f388f46bcb2c199f516d8bdcc Mon Sep 17 00:00:00 2001 From: BOHA Date: Sat, 6 Jun 2026 21:02:39 +0200 Subject: [PATCH] fix(mui): ConfirmDialog retains text during close transition (no empty fade-out) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The message was bound to the caller's selected row, which gets nulled on close at the same instant the Dialog begins its fade-out — so it faded out with empty text. Now the dialog caches the last shown title/message and renders that through the exit transition. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/admin/ui/ConfirmDialog.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/admin/ui/ConfirmDialog.tsx b/src/admin/ui/ConfirmDialog.tsx index bd0f935..2f8663a 100644 --- a/src/admin/ui/ConfirmDialog.tsx +++ b/src/admin/ui/ConfirmDialog.tsx @@ -1,3 +1,4 @@ +import { useRef } from "react"; import Dialog from "@mui/material/Dialog"; import DialogTitle from "@mui/material/DialogTitle"; import DialogContent from "@mui/material/DialogContent"; @@ -29,15 +30,21 @@ export default function ConfirmDialog({ confirmVariant = "primary", loading = false, }: ConfirmDialogProps) { + // Retain the last shown title/message so the close (fade-out) transition + // doesn't flash empty when the caller clears its source data (e.g. sets the + // selected row to null) at the same moment it closes the dialog. + const shown = useRef({ title, message }); + if (isOpen) shown.current = { title, message }; + return ( - {title} + {shown.current.title} - {message} + {shown.current.message}