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

fix[angular-gen2]: new blocks getting added on top in case of components that use children #3977

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sidmohanty11
Copy link
Contributor

@sidmohanty11 sidmohanty11 commented Mar 19, 2025

Description

A similar case to this: #3932 but happens inside ComponentRef where we render children separately as <Blocks /> inside the template.

Jira
https://builder-io.atlassian.net/browse/ENG-7718

Screenshot
If relevant, add a screenshot or two of the changes you made.

Copy link

changeset-bot bot commented Mar 19, 2025

🦋 Changeset detected

Latest commit: c54a3ab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@builder.io/sdk-angular Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

nx-cloud bot commented Mar 19, 2025

View your CI Pipeline Execution ↗ for commit c54a3ab.

Command Status Duration Result
nx test @e2e/nuxt ✅ Succeeded 7m 44s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-20 11:01:37 UTC

@sidmohanty11 sidmohanty11 requested review from a team, rima-builder and samijaber and removed request for a team March 19, 2025 09:32
// @ts-expect-error - 'changes' comes from Angular's ngOnChanges hook
!changes['blockChildren']?.isFirstChange() &&
// @ts-expect-error - 'changes' comes from Angular's ngOnChanges hook
JSON.stringify(changes['blockChildren']?.previousValue) !==
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this a massive cost, stringifying the entire block children on every ngOnChanges?

Copy link
Contributor

Choose a reason for hiding this comment

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

any way it can be avoided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, updated the logic to only check for changes in blockChildren, had to add the previousValue && currVal !== 0 as getter will send a new empty array every time the change detection runs

loom of the approach:
https://www.loom.com/share/5c3c3952775442099ef5dc6ba626d340

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.

2 participants