From db68b021b79a9748e594e63fd6a6d13cabc7ce8e Mon Sep 17 00:00:00 2001 From: Alex TYRODE Date: Mon, 5 May 2025 04:34:59 +0000 Subject: [PATCH] feat: enhance pad deletion handling in PadsDialog - Updated the handleLoadPad function to accept a parameter for keeping the dialog open when switching pads. - Modified the logic to only close the dialog if the keepDialogOpen parameter is false, improving user experience during pad deletion. --- src/frontend/src/ui/PadsDialog.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/ui/PadsDialog.tsx b/src/frontend/src/ui/PadsDialog.tsx index 632ee3d..64a3772 100644 --- a/src/frontend/src/ui/PadsDialog.tsx +++ b/src/frontend/src/ui/PadsDialog.tsx @@ -119,11 +119,11 @@ const PadsDialog: React.FC = ({ padName: pad.display_name }); - // If deleting the active pad, switch to another pad first + // If deleting the active pad, switch to another pad first but keep dialog open if (pad.id === activePadId && pads) { const otherPad = pads.find(p => p.id !== pad.id); if (otherPad && excalidrawAPI) { - handleLoadPad(otherPad); + handleLoadPad(otherPad, true); // Pass true to keep dialog open } } @@ -131,7 +131,7 @@ const PadsDialog: React.FC = ({ deletePad(pad.id); }; - const handleLoadPad = (pad: PadData) => { + const handleLoadPad = (pad: PadData, keepDialogOpen: boolean = false) => { if (!excalidrawAPI) return; // Save the current canvas before switching tabs @@ -147,8 +147,10 @@ const PadsDialog: React.FC = ({ // Load the pad data loadPadData(excalidrawAPI, pad.id, pad.data); - // Close the dialog - handleClose(); + // Close the dialog only if keepDialogOpen is false + if (!keepDialogOpen) { + handleClose(); + } }; // Format date function