-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(cdk/tree): add trackBy functionality to NestedTreeControl #19602
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
feat(cdk/tree): add trackBy functionality to NestedTreeControl #19602
Conversation
@@ -196,6 +197,24 @@ describe('CdkNestedTreeControl', () => { | |||
}); | |||
}); | |||
}); | |||
|
|||
it('maintains node expansion state based on trackBy function, if provided', () => { | |||
const treeControl = new NestedTreeControl<TestData, string>(getChildren); |
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.
Instead of adding the trackBy directly, can you utilize the new constructor options
arg here? That would be closer to the implementation we expect users to have
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.
Sounds good, updated this test to use the options
arg. I initially was copying what was done for FlatTreeControl, should I update that test to use FlatTreeControl's options
as well?
treeControl.trackBy = (node: TestData) => `${node.a} ${node.b} ${node.c}`; |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The ability to track tree-node expansion via a trackBy function was added to FlatTreeControl in #18708. This PR adds the same functionality to NestedTreeControl to allow nested trees the ability to also specify an alternative method of tracking a node's expansion status.