Skip to content

Commit b087f66

Browse files
authored
feat: enhance pad deletion handling in PadsDialog (#82)
- 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.
1 parent 86490a2 commit b087f66

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/frontend/src/ui/PadsDialog.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,19 @@ const PadsDialog: React.FC<PadsDialogProps> = ({
119119
padName: pad.display_name
120120
});
121121

122-
// If deleting the active pad, switch to another pad first
122+
// If deleting the active pad, switch to another pad first but keep dialog open
123123
if (pad.id === activePadId && pads) {
124124
const otherPad = pads.find(p => p.id !== pad.id);
125125
if (otherPad && excalidrawAPI) {
126-
handleLoadPad(otherPad);
126+
handleLoadPad(otherPad, true); // Pass true to keep dialog open
127127
}
128128
}
129129

130130
// Call the deletePad mutation
131131
deletePad(pad.id);
132132
};
133133

134-
const handleLoadPad = (pad: PadData) => {
134+
const handleLoadPad = (pad: PadData, keepDialogOpen: boolean = false) => {
135135
if (!excalidrawAPI) return;
136136

137137
// Save the current canvas before switching tabs
@@ -147,8 +147,10 @@ const PadsDialog: React.FC<PadsDialogProps> = ({
147147
// Load the pad data
148148
loadPadData(excalidrawAPI, pad.id, pad.data);
149149

150-
// Close the dialog
151-
handleClose();
150+
// Close the dialog only if keepDialogOpen is false
151+
if (!keepDialogOpen) {
152+
handleClose();
153+
}
152154
};
153155

154156
// Format date function

0 commit comments

Comments
 (0)