Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split grid move strategies #6606

Merged
merged 38 commits into from
Nov 5, 2024
Merged

Split grid move strategies #6606

merged 38 commits into from
Nov 5, 2024

Conversation

ruggi
Copy link
Contributor

@ruggi ruggi commented Oct 31, 2024

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

Copy link
Contributor

github-actions bot commented Oct 31, 2024

Try me

Copy link

relativeci bot commented Oct 31, 2024

#15036 Bundle Size — 58.05MiB (~+0.01%).

945b36f(current) vs d1d46c1 master#15035(baseline)

Warning

Bundle contains 70 duplicate packages – View duplicate packages

Bundle metrics  Change 3 changes Regression 1 regression
                 Current
#15036
     Baseline
#15035
Regression  Initial JS 41.03MiB(+0.01%) 41.02MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 18.08% 18.25%
No change  Chunks 20 20
No change  Assets 22 22
Change  Modules 4166(+0.02%) 4165
No change  Duplicate Modules 213 213
No change  Duplicate Code 27.31% 27.31%
No change  Packages 477 477
No change  Duplicate Packages 70 70
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#15036
     Baseline
#15035
Regression  JS 58.04MiB (~+0.01%) 58.04MiB
Improvement  HTML 7.37KiB (-0.25%) 7.39KiB

Bundle analysis reportBranch chore/split-grid-move-stratsProject dashboard


Generated by RelativeCIDocumentationReport issue

ruggi added 4 commits October 31, 2024 11:59
@ruggi ruggi marked this pull request as ready for review October 31, 2024 15:41
ruggi added 2 commits October 31, 2024 16:49
@@ -273,7 +273,7 @@ function gridReparentCommands(

const gridPropsCommands =
gridCellGlobalFrames != null && gridTemplate != null
? runGridRearrangeMove(
? runGridMoveRearrange(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably more like a a followup PR problem, but I think this is a regression, this way reparent to grid always uses rearrange, so there is no way to just drop an element into a grid without it getting pinned down (which was possible before this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, but imo this is something to be done with a followup PR, because we need to decide how to tackle this interaction between blending strategies

}
const { mouseCellPosInOriginalElement } = gridConfig

const gridPath = EP.parentPath(pathForCommands)
Copy link
Contributor

@balazsbajorics balazsbajorics Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not related to this PR, but please leave a comment here that this needs to be deleted – we do not know if EP.parentPath points to a grid or not, nor should we know that. we are tracking this work as part of the components suppport in the paper doc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, I marked all usages with comments

default:
assertNever(moveType)
}
}

export function runGridMoveReorder(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just reorder, right? no need to have move in the name anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but for consistency I kept the naming prefixes, imho naming must be fixed (e.g. "rearrange") but incrementally

@@ -155,6 +130,7 @@ export function runGridRearrangeMove(
gridPath,
targetCellData?.gridCellCoordinates ?? null,
gridCellCoordinates(row, column),
'valid',
)

switch (moveType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels wrong that runGridMoveRearrange has to deal with absolute move – in a follow-up PR, we should run the real absolute strategy and remove absolute-related code from here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolute has been taken out into its own strategy

@ruggi ruggi marked this pull request as draft November 4, 2024 14:52
ruggi added 7 commits November 4, 2024 15:52
ruggi added 5 commits November 5, 2024 11:25
@ruggi ruggi marked this pull request as ready for review November 5, 2024 15:35
@ruggi ruggi merged commit bee47ee into master Nov 5, 2024
16 checks passed
@ruggi ruggi deleted the chore/split-grid-move-strats branch November 5, 2024 17:07
ruggi added a commit that referenced this pull request Nov 7, 2024
**Problem:**

The grid "move" strategies should be renamed to better reflect what they
do and to be less confusing.

**Fix:**
This PR is a followup to
#6606

1. Rename "move rearrange" to "change grid element location" (and
duplicate)
2. Rename "move reorder" to "reorder"

Fixes #6620

---------

Co-authored-by: Federico Ruggi <federico.ruggi@shopify.com>
liady pushed a commit that referenced this pull request Dec 13, 2024
**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
liady pushed a commit that referenced this pull request Dec 13, 2024
**Problem:**

The grid "move" strategies should be renamed to better reflect what they
do and to be less confusing.

**Fix:**
This PR is a followup to
#6606

1. Rename "move rearrange" to "change grid element location" (and
duplicate)
2. Rename "move reorder" to "reorder"

Fixes #6620

---------

Co-authored-by: Federico Ruggi <federico.ruggi@shopify.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split grid move strategies
4 participants