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

Wrap in List #5722

Merged
merged 14 commits into from
May 23, 2024
Merged

Wrap in List #5722

merged 14 commits into from
May 23, 2024

Conversation

liady
Copy link
Contributor

@liady liady commented May 22, 2024

Problem:
We cannot currently wrap with a List

Fix:
This PR fixes wrapping a single element with a list.

Details:

  1. Adding a List as an option for "Wrap..."
  2. Adjust the code so that wrapping in a map (which is currently two INSERTs in disguise) will actually REPLACE the map contents
  3. NOTE - this PR supports a single element wrapping.

For multiple element wrapping see #5696

Monosnap.screencast.2024-05-22.19-27-29.mp4

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

Fixes #5419

Copy link
Contributor

github-actions bot commented May 22, 2024

Try me

Copy link

relativeci bot commented May 22, 2024

#12613 Bundle Size — 62.18MiB (+0.01%).

f049c47(current) vs 6339ece master#12608(baseline)

Warning

Bundle contains 52 duplicate packages – View duplicate packages

Bundle metrics  Change 3 changes Regression 1 regression
                 Current
#12613
     Baseline
#12608
Regression  Initial JS 45.25MiB(+0.01%) 45.24MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 22.05% 21.42%
No change  Chunks 30 30
No change  Assets 33 33
No change  Modules 4290 4290
No change  Duplicate Modules 520 520
Change  Duplicate Code 31.01%(-0.03%) 31.02%
No change  Packages 449 449
No change  Duplicate Packages 52 52
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#12613
     Baseline
#12608
Regression  JS 62.17MiB (+0.01%) 62.16MiB
Improvement  HTML 11.16KiB (-0.33%) 11.2KiB

Bundle analysis reportBranch feat/wrap-in-listProject dashboard

Copy link
Contributor

github-actions bot commented May 22, 2024

Performance test results:
(Chart1)
(Chart2)

@liady liady marked this pull request as ready for review May 22, 2024 17:08
@liady liady changed the title WIP - Wrap in List Wrap in List May 22, 2024
export interface MapInsertionPath {
type: 'MAP_INSERTION'
intendedParentPath: StaticElementPath
insertBehavior: ConditionalClauseInsertBehavior
Copy link
Contributor

Choose a reason for hiding this comment

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

This type should probably be renamed

Copy link
Contributor

Choose a reason for hiding this comment

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

for the note, we agreed not to go with MapInsertionPath at all

@@ -2318,6 +2318,15 @@ export const MetadataUtils = {
const element = MetadataUtils.findElementByElementPath(metadata, target)
return MetadataUtils.isJSXMapExpressionFromMetadata(element)
},
isJSXElementFromMetadata(element: ElementInstanceMetadata | null): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised these two don't already exist, though we do have getJSXElementFromMetadata and getJSXElementFromElementInstanceMetadata

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I followed the isConditionalFromMetadata, isJSXMapExpressionFromMetadata, etc pattern here - should I leave it like this (for completion and for the next developer who will need it and look for it) or do you think I need to use the getJSXElement... methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so maybe we should leave this method for completion and for next developers, if that makes sense

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, keep the function 👍

@@ -1228,3 +1232,7 @@ export function multiplePathsAllWithTheSameUID(paths: Array<ElementPath>): boole
}
return false
}

export function isIndexedElement(path: ElementPath): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, we have isDynamicPath which does the same thing but in a different way. I'm not sure which would be better now tbh

@liady liady merged commit 17a8370 into master May 23, 2024
16 checks passed
@liady liady deleted the feat/wrap-in-list branch May 23, 2024 16:09
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.

Wrap in List!
3 participants