Skip to content

Commit bee47ee

Browse files
authored
Split grid move strategies (#6606)
**Problem:** The move strategies for grids should be split both functionally as well as implementation-wise. **Fix:** This PR does a bunch of things in order to clean up the grid move strategies: - Remove the swap strategy - Split the rearrange strategy into two distinct strategies: rearrange and reorder - Take out the absolute move portions out of the rearrange strategy into their own strategy - The reorder strategy performs in-flow moves - The rearrange strategy performs pinned moves - When the reorder strategy is active, don't show the animation as well as the target cell outline - For pinned elements, give precedence to the rearrange strategy - For in-flow elements, give precedence to the reorder strategy - Marked all usages of `EP.parentPath` to detect the parent grid as `TODO` for a future PR fixing that in favor of actual grid metadata **Note:** Imho the tests should be also split in two, in this PR I only updated the existing ones (which are still relevant tho!) but it'd be good to have an incremental PR to do that split as well. Fixes #6607
1 parent 03865fc commit bee47ee

19 files changed

+1289
-1129
lines changed

editor/src/components/canvas/canvas-strategies/canvas-strategies.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import { createSelector } from 'reselect'
32
import { mapDropNulls, pushUniquelyBy, sortBy } from '../../../core/shared/array-utils'
43
import type { ElementInstanceMetadataMap } from '../../../core/shared/element-template'
54
import { arrayEqualsByReference, assertNever } from '../../../core/shared/utils'
@@ -68,11 +67,10 @@ import type { InsertionSubject, InsertionSubjectWrapper } from '../../editor/edi
6867
import { generateUidWithExistingComponents } from '../../../core/model/element-template-utils'
6968
import { retargetStrategyToChildrenOfFragmentLikeElements } from './strategies/fragment-like-helpers'
7069
import { MetadataUtils } from '../../../core/model/element-metadata-utils'
71-
import { gridRearrangeMoveStrategy } from './strategies/grid-rearrange-move-strategy'
70+
import { gridMoveRearrangeStrategy } from './strategies/grid-move-rearrange-strategy'
7271
import { resizeGridStrategy } from './strategies/resize-grid-strategy'
73-
import { rearrangeGridSwapStrategy } from './strategies/rearrange-grid-swap-strategy'
7472
import { gridResizeElementStrategy } from './strategies/grid-resize-element-strategy'
75-
import { gridRearrangeMoveDuplicateStrategy } from './strategies/grid-rearrange-move-duplicate-strategy'
73+
import { gridMoveRearrangeDuplicateStrategy } from './strategies/grid-move-rearrange-duplicate-strategy'
7674
import { setGridGapStrategy } from './strategies/set-grid-gap-strategy'
7775
import type { CanvasCommand } from '../commands/commands'
7876
import { foldAndApplyCommandsInner } from '../commands/commands'
@@ -89,6 +87,8 @@ import {
8987
GridControls,
9088
isGridControlsProps,
9189
} from '../controls/grid-controls-for-strategies'
90+
import { gridMoveReorderStrategy } from './strategies/grid-move-reorder-strategy'
91+
import { gridMoveAbsoluteStrategy } from './strategies/grid-move-absolute'
9292

9393
export type CanvasStrategyFactory = (
9494
canvasState: InteractionCanvasState,
@@ -116,10 +116,11 @@ const moveOrReorderStrategies: MetaCanvasStrategy = (
116116
convertToAbsoluteAndMoveStrategy,
117117
convertToAbsoluteAndMoveAndSetParentFixedStrategy,
118118
reorderSliderStategy,
119-
gridRearrangeMoveStrategy,
120-
rearrangeGridSwapStrategy,
121-
gridRearrangeMoveDuplicateStrategy,
119+
gridMoveRearrangeStrategy,
120+
gridMoveRearrangeDuplicateStrategy,
121+
gridMoveReorderStrategy,
122122
gridRearrangeResizeKeyboardStrategy,
123+
gridMoveAbsoluteStrategy,
123124
],
124125
)
125126
}

0 commit comments

Comments
 (0)