Skip to content

Commit

Permalink
Make grid rearrange work in grid components (#6589)
Browse files Browse the repository at this point in the history
**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
  • Loading branch information
gbalint authored Oct 25, 2024
1 parent 45649c6 commit ac18c51
Show file tree
Hide file tree
Showing 14 changed files with 4,875 additions and 709 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,23 @@ Object {
"y": 0,
},
"padding": Object {},
"parentContainerGridProperties": Object {
"gridAutoColumns": null,
"gridAutoFlow": null,
"gridAutoRows": null,
"gridTemplateColumns": null,
"gridTemplateRows": null,
},
"parentContainerGridPropertiesFromProps": Object {
"gridAutoColumns": null,
"gridAutoFlow": null,
"gridAutoRows": null,
"gridTemplateColumns": null,
"gridTemplateRows": null,
},
"parentFlexDirection": null,
"parentFlexGap": 0,
"parentGridCellGlobalFrames": null,
"parentHugsOnMainAxis": false,
"parentJustifyContent": null,
"parentLayoutSystem": "flow",
Expand Down Expand Up @@ -383,8 +398,23 @@ Object {
"y": 0,
},
"padding": Object {},
"parentContainerGridProperties": Object {
"gridAutoColumns": null,
"gridAutoFlow": null,
"gridAutoRows": null,
"gridTemplateColumns": null,
"gridTemplateRows": null,
},
"parentContainerGridPropertiesFromProps": Object {
"gridAutoColumns": null,
"gridAutoFlow": null,
"gridAutoRows": null,
"gridTemplateColumns": null,
"gridTemplateRows": null,
},
"parentFlexDirection": null,
"parentFlexGap": 0,
"parentGridCellGlobalFrames": null,
"parentHugsOnMainAxis": false,
"parentJustifyContent": null,
"parentLayoutSystem": "flow",
Expand Down
Loading

0 comments on commit ac18c51

Please sign in to comment.