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

Filtered replace element options to avoid losing children. #5678

Merged
merged 1 commit into from
May 15, 2024

Conversation

seanparsons
Copy link
Contributor

Problem:
It's possible to define components which include their own children, but swapping a particular element with those will result in the original children of the element being lost.

Fix:
The main crux of this is just a check (in the two most appropriate places they appeared to apply) which checks if the following conditions hold:

  • The element is being replaced, instead of fully swapped out.
  • The current element has child elements..
  • The new element also defines its own child elements.
    If all of those conditions hold then the component definition is excluded from the listing.

Commit Details:

  • Added componentElementToInsertHasChildren function.
  • Adapted preferredChildrenForTarget to perform the filtering which removes components that wont preserve children.
  • Added getTargetParentFromInsertionTarget function.
  • Adapted ComponentPickerContextMenuFull component to perform the filtering which removes components that wont preserve children.

Manual Tests:
I hereby swear that:

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

Fixes #5650

…hildren.

- Added `componentElementToInsertHasChildren` function.
- Adapted `preferredChildrenForTarget` to perform the filtering which removes
  components that wont preserve children.
- Added `getTargetParentFromInsertionTarget` function.
- Adapted `ComponentPickerContextMenuFull` component to perform the filtering
  which removes components that wont preserve children.
Copy link
Contributor

github-actions bot commented May 14, 2024

Try me

Copy link

relativeci bot commented May 14, 2024

#12439 Bundle Size — 62.54MiB (~+0.01%).

55dd881(current) vs 6339ece master#12438(baseline)

Warning

Bundle contains 58 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
#12439
     Baseline
#12438
Regression  Initial JS 45.6MiB(~+0.01%) 45.6MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 21.8% 21.78%
No change  Chunks 31 31
No change  Assets 34 34
No change  Modules 4386 4386
No change  Duplicate Modules 511 511
No change  Duplicate Code 30.82% 30.82%
No change  Packages 468 468
No change  Duplicate Packages 58 58
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#12439
     Baseline
#12438
Regression  JS 62.53MiB (~+0.01%) 62.53MiB
Improvement  HTML 10.94KiB (-0.34%) 10.98KiB

Bundle analysis reportBranch feature/filtered-replace-element...Project dashboard

Copy link
Contributor

Performance test results:
(Chart1)
(Chart2)

@seanparsons seanparsons merged commit 2264ac1 into master May 15, 2024
16 checks passed
@seanparsons seanparsons deleted the feature/filtered-replace-element-options branch May 15, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants