Skip to content

Commit d3f776e

Browse files
committed
[Controls Anywhere] Fix reordering controls on delete
1 parent c8517cf commit d3f776e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager

src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/layout_manager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,12 @@ export function initializeLayoutManager(
300300
layout$.next({ ...layout$.value, panels });
301301
} else if (controls[uuid]) {
302302
delete controls[uuid];
303-
layout$.next({ ...layout$.value, controls });
303+
// Recompute the order of the remaining controls
304+
const nextControls: typeof controls = Object.entries(controls)
305+
.sort(([, a], [, b]) => a.order - b.order)
306+
.map(([key, value], i) => [key, { ...value, order: i }])
307+
.reduce((result, [key, value]) => ({ ...result, [key as string]: value }), {});
308+
layout$.next({ ...layout$.value, controls: nextControls });
304309
}
305310

306311
const children = { ...children$.value };

0 commit comments

Comments
 (0)