Skip to content

Commit 0b58aef

Browse files
authored
Fix Diagram Grid Layout inconsistent layout at card removal (#3037)
* fix(DGL): Do not pop because it removes the entry from the original array. Just check the size without modification of the array. Signed-off-by: sBouzols <[email protected]>
1 parent 7defe43 commit 0b58aef

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/components/diagrams/diagram-grid-layout.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,7 @@ function DiagramGridLayout({ studyUuid, showInSpreadsheet, visible }: Readonly<D
136136
};
137137

138138
const removeLayoutItem = (cardUuid: UUID) => {
139-
setLayouts((old_layouts) => {
140-
const oldLayoutsEntries = Object.entries(old_layouts);
141-
if (oldLayoutsEntries.pop()?.[1].length === 2) {
142-
return initialLayouts; // Reset to initial layouts if no diagrams left
143-
}
144-
const newLayoutsEntries = removeInLayoutEntries(oldLayoutsEntries, cardUuid);
145-
return Object.fromEntries(newLayoutsEntries);
146-
});
139+
setLayouts((old_layouts) => Object.fromEntries(removeInLayoutEntries(Object.entries(old_layouts), cardUuid)));
147140
};
148141

149142
const stopDiagramBlinking = useCallback((diagramUuid: UUID) => {

0 commit comments

Comments
 (0)