-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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(cdk/tree): react properly to expansion changes #29751
base: main
Are you sure you want to change the base?
fix(cdk/tree): react properly to expansion changes #29751
Conversation
@@ -223,6 +225,10 @@ export class CdkTree<T, K = T> | |||
}) | |||
_nodeDefs: QueryList<CdkTreeNodeDef<T>>; | |||
|
|||
// signals? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover?
sub.unsubscribe(); | ||
}); | ||
}, | ||
{allowSignalWrites: true}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use computed
instead of writing inside of an effect?
@@ -16,6 +16,7 @@ describe('CdkTree when provided LegacyTreeKeyManager', () => { | |||
|
|||
fixture = TestBed.createComponent(SimpleCdkTreeApp); | |||
fixture.detectChanges(); | |||
fixture.detectChanges(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These consecutive detectChanges
calls seem a bit suspicious. Do we know why they're necessary?
@@ -433,6 +449,8 @@ export class CdkTree<T, K = T> | |||
this._updateCachedData(data.flattenedNodes); | |||
this.renderNodeChanges(data.renderNodes); | |||
this._updateKeyManagerItems(data.flattenedNodes); | |||
// Explicitly detect the initial set of changes to this component subtree | |||
this._changeDetectorRef.detectChanges(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #29669. This converts parts of the rendering pipeline to use signals which allows Angular to properly detect changes to the underlying data which may be caused by rendering new nodes. rxjs didn't handle this correctly as the data subscriptions were only set after the initial callback was run, causing partial updates.