From 2779ddd7b606d3b87d29d8cf1fb635534893eb07 Mon Sep 17 00:00:00 2001 From: Federico Ruggi <1081051+ruggi@users.noreply.github.com> Date: Tue, 8 Oct 2024 10:00:34 +0200 Subject: [PATCH] Fix duplicate grid control keys (#6474) **Problem:** The grid controls show a bunch of duplicate keys while active. **Fix:** The problem is that there may be multiple instances of the same grid being rendered caused by how they are initialized, so this PS cleans that up. Fixes #6473 --- editor/src/components/canvas/controls/grid-controls.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/src/components/canvas/controls/grid-controls.tsx b/editor/src/components/canvas/controls/grid-controls.tsx index 9f23bff592dd..89ae8fbed134 100644 --- a/editor/src/components/canvas/controls/grid-controls.tsx +++ b/editor/src/components/canvas/controls/grid-controls.tsx @@ -20,7 +20,7 @@ import { printGridCSSNumber, } from '../../../components/inspector/common/css-utils' import { MetadataUtils } from '../../../core/model/element-metadata-utils' -import { mapDropNulls, stripNulls } from '../../../core/shared/array-utils' +import { mapDropNulls, stripNulls, uniqBy } from '../../../core/shared/array-utils' import { defaultEither } from '../../../core/shared/either' import * as EP from '../../../core/shared/element-path' import type { @@ -1137,7 +1137,7 @@ export const GridControls = controlForStrategyMemoized(({ tar 'GridControls hoveredGrids', ) - const grids = useGridData([...targets, ...hoveredGrids]) + const grids = useGridData(uniqBy([...targets, ...hoveredGrids], (a, b) => EP.pathsEqual(a, b))) if (grids.length === 0) { return null