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

Make grid rearrange work in grid components #6589

Merged
merged 3 commits into from
Oct 25, 2024
Merged

Conversation

gbalint
Copy link
Contributor

@gbalint gbalint commented Oct 25, 2024

Problem:
Grid rearrange does not work when the grid is a root element of a component.

Fix:
The problem is that we assume that the parent element of a grid item is the grid itself. However, when the grid is in a component, the parent element is the component instance, and not the grid element inside it. This is a problem because we can not find the grid measurement helper from the parent element path.

The solution is that all necessary grid related measurement data should be available in the metadata of the grid items themselves.

  • Added new fields to specialSizeMeasurements about the parent grid
  • Rewrote grid rearrange strategies and helpers to rely on the specialSizeMeasurements of the item, and not of the parent.

Still unsolved:

  • Grid strategies set the props of the grid controls (e.g. to show which is the highlighted cell). These still assume that the control is on the parent, which is true in cases when the grid is root element of a component. Solving the problem for more problematic cases is out of scope for this PR.

Manual Tests:
I hereby swear that:

  • I opened a hydrogen project and it loaded
  • I could navigate to various routes in Play mode

Copy link
Contributor

github-actions bot commented Oct 25, 2024

Try me

Copy link

relativeci bot commented Oct 25, 2024

#14932 Bundle Size — 57.98MiB (~+0.01%).

3bb7351(current) vs 916e8b9 master#14928(baseline)

Warning

Bundle contains 70 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
#14932
     Baseline
#14928
Regression  Initial JS 40.97MiB(~+0.01%) 40.96MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 18% 0%
No change  Chunks 20 20
No change  Assets 22 22
No change  Modules 4152 4152
No change  Duplicate Modules 213 213
No change  Duplicate Code 27.33% 27.33%
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
#14932
     Baseline
#14928
Regression  JS 57.98MiB (~+0.01%) 57.97MiB
Improvement  HTML 7.37KiB (-0.25%) 7.39KiB

Bundle analysis reportBranch fix/grid-componentsProject dashboard


Generated by RelativeCIDocumentationReport issue

@gbalint gbalint marked this pull request as ready for review October 25, 2024 14:12
@gbalint gbalint merged commit ac18c51 into master Oct 25, 2024
15 checks passed
@gbalint gbalint deleted the fix/grid-components branch October 25, 2024 19:25
gbalint added a commit that referenced this pull request Oct 30, 2024
**Problem:**
Fix grid-element-resize strategy in grid components.

**Fix:**
Similarly to #6589 , use
the specialSizeMeasurements of the grid item to get the grid properties
(and not the parent element)

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Play mode
liady pushed a commit that referenced this pull request Dec 13, 2024
**Problem:**
Grid rearrange does not work when the grid is a root element of a
component.

**Fix:**
The problem is that we assume that the parent element of a grid item is
the grid itself. However, when the grid is in a component, the parent
element is the component instance, and not the grid element inside it.
This is a problem because we can not find the grid measurement helper
from the parent element path.

The solution is that all necessary grid related measurement data should
be available in the metadata of the grid items themselves.

- Added new fields to specialSizeMeasurements about the parent grid
- Rewrote grid rearrange strategies and helpers to rely on the
specialSizeMeasurements of the item, and not of the parent.

Still unsolved:
- Grid strategies set the props of the grid controls (e.g. to show which
is the highlighted cell). These still assume that the control is on the
parent, which is true in cases when the grid is root element of a
component. Solving the problem for more problematic cases is out of
scope for this PR.

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Play mode
liady pushed a commit that referenced this pull request Dec 13, 2024
**Problem:**
Fix grid-element-resize strategy in grid components.

**Fix:**
Similarly to #6589 , use
the specialSizeMeasurements of the grid item to get the grid properties
(and not the parent element)

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Play mode
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.

3 participants