Skip to content

Commit

Permalink
Remove ElementInstanceMetadata.localFrame. (#6256)
Browse files Browse the repository at this point in the history
**Problem:**
It would appear that we don't _really_ need
`ElementInstanceMetadata.localFrame` and can instead easily calculate
it.

**Fix:**
The supposition that we don't need `localFrame` was actually true, it
can instead be calculated comparatively simply from the `globalFrame` of
the target and that of one of the ancestors. Originally it was thought
that the latter would be the parent and in most cases it is, however if
the target is the root component of an instance, then the parent will
have an identical value for `globalFrame` and instead we need the
grandparent of the target.

**Commit Details:**
- Removed the field `localFrame` from `ElementInstanceMetadata` and also
from the relevant factory function.
- Included the whole editor metadata in the metadata that `pressKeys`
creates so that it's possible to obtain the element metadata for the
parent.
- Replaced lookups of `localFrame` with calls to
`MetadataUtils.getFrame`.
- Implemented `MetadataUtils.getFrame` to lookup the global frames for
an element and its parent (mostly) and to then calculate the local frame
from their difference.

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

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Preview mode
  • Loading branch information
seanparsons authored Aug 26, 2024
1 parent 36e3f99 commit cac3d9c
Show file tree
Hide file tree
Showing 38 changed files with 154 additions and 592 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ Object {
},
"isEmotionOrStyledComponent": false,
"label": null,
"localFrame": null,
"nonRoundedGlobalFrame": null,
"specialSizeMeasurements": Object {
"alignItems": null,
Expand Down Expand Up @@ -303,7 +302,6 @@ Object {
},
"isEmotionOrStyledComponent": false,
"label": null,
"localFrame": null,
"nonRoundedGlobalFrame": null,
"specialSizeMeasurements": Object {
"alignItems": null,
Expand Down
Loading

0 comments on commit cac3d9c

Please sign in to comment.