Skip to content

Commit

Permalink
Fix duplicate grid control keys (#6474)
Browse files Browse the repository at this point in the history
**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
  • Loading branch information
ruggi authored Oct 8, 2024
1 parent c5f1d00 commit 2779ddd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions editor/src/components/canvas/controls/grid-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1137,7 +1137,7 @@ export const GridControls = controlForStrategyMemoized<GridControlsProps>(({ 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
Expand Down

0 comments on commit 2779ddd

Please sign in to comment.