fix: clone panel randomly jumping around in the middle causing layout issues (#5161)

This commit is contained in:
Vikrant Gupta 2024-06-06 17:16:14 +05:30 committed by GitHub
parent c53e6de689
commit a17928df88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,15 +131,22 @@ function WidgetGraphComponent({
const uuid = v4(); const uuid = v4();
// this is added to make sure the cloned panel is of the same dimensions as the original one
const originalPanelLayout = selectedDashboard.data.layout?.find(
(l) => l.i === widget.id,
);
// added the cloned panel on the top as it is given most priority when arranging
// in the layout. React_grid_layout assigns priority from top, hence no random position for cloned panel
const layout = [ const layout = [
...(selectedDashboard.data.layout || []),
{ {
i: uuid, i: uuid,
w: 6, w: originalPanelLayout?.w || 6,
x: 0, x: 0,
h: 6, h: originalPanelLayout?.h || 6,
y: 0, y: 0,
}, },
...(selectedDashboard.data.layout || []),
]; ];
updateDashboardMutation.mutateAsync( updateDashboardMutation.mutateAsync(