Skip to content

Commit

Permalink
Split grid move strategies (#6606)
Browse files Browse the repository at this point in the history
**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
  • Loading branch information
ruggi authored Nov 5, 2024
1 parent 03865fc commit bee47ee
Show file tree
Hide file tree
Showing 19 changed files with 1,289 additions and 1,129 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import { createSelector } from 'reselect'
import { mapDropNulls, pushUniquelyBy, sortBy } from '../../../core/shared/array-utils'
import type { ElementInstanceMetadataMap } from '../../../core/shared/element-template'
import { arrayEqualsByReference, assertNever } from '../../../core/shared/utils'
Expand Down Expand Up @@ -68,11 +67,10 @@ import type { InsertionSubject, InsertionSubjectWrapper } from '../../editor/edi
import { generateUidWithExistingComponents } from '../../../core/model/element-template-utils'
import { retargetStrategyToChildrenOfFragmentLikeElements } from './strategies/fragment-like-helpers'
import { MetadataUtils } from '../../../core/model/element-metadata-utils'
import { gridRearrangeMoveStrategy } from './strategies/grid-rearrange-move-strategy'
import { gridMoveRearrangeStrategy } from './strategies/grid-move-rearrange-strategy'
import { resizeGridStrategy } from './strategies/resize-grid-strategy'
import { rearrangeGridSwapStrategy } from './strategies/rearrange-grid-swap-strategy'
import { gridResizeElementStrategy } from './strategies/grid-resize-element-strategy'
import { gridRearrangeMoveDuplicateStrategy } from './strategies/grid-rearrange-move-duplicate-strategy'
import { gridMoveRearrangeDuplicateStrategy } from './strategies/grid-move-rearrange-duplicate-strategy'
import { setGridGapStrategy } from './strategies/set-grid-gap-strategy'
import type { CanvasCommand } from '../commands/commands'
import { foldAndApplyCommandsInner } from '../commands/commands'
Expand All @@ -89,6 +87,8 @@ import {
GridControls,
isGridControlsProps,
} from '../controls/grid-controls-for-strategies'
import { gridMoveReorderStrategy } from './strategies/grid-move-reorder-strategy'
import { gridMoveAbsoluteStrategy } from './strategies/grid-move-absolute'

export type CanvasStrategyFactory = (
canvasState: InteractionCanvasState,
Expand Down Expand Up @@ -116,10 +116,11 @@ const moveOrReorderStrategies: MetaCanvasStrategy = (
convertToAbsoluteAndMoveStrategy,
convertToAbsoluteAndMoveAndSetParentFixedStrategy,
reorderSliderStategy,
gridRearrangeMoveStrategy,
rearrangeGridSwapStrategy,
gridRearrangeMoveDuplicateStrategy,
gridMoveRearrangeStrategy,
gridMoveRearrangeDuplicateStrategy,
gridMoveReorderStrategy,
gridRearrangeResizeKeyboardStrategy,
gridMoveAbsoluteStrategy,
],
)
}
Expand Down
Loading

0 comments on commit bee47ee

Please sign in to comment.