Skip to content

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

Merged
merged 4 commits into from
Jun 29, 2020

Conversation

tjaneczko
Copy link
Contributor

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.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 10, 2020
@@ -196,6 +197,24 @@ describe('CdkNestedTreeControl', () => {
});
});
});

it('maintains node expansion state based on trackBy function, if provided', () => {
const treeControl = new NestedTreeControl<TestData, string>(getChildren);
Copy link
Contributor

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

Copy link
Contributor Author

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}`;

@tjaneczko tjaneczko changed the title Add trackBy functionality to NestedTreeControl feat(cdk/tree): add trackBy functionality to NestedTreeControl Jun 15, 2020
@tjaneczko tjaneczko requested a review from andrewseguin June 15, 2020 23:40
@jelbourn jelbourn added the G This is is related to a Google internal issue label Jun 24, 2020
@andrewseguin andrewseguin added lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jun 25, 2020
@jelbourn jelbourn added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jun 29, 2020
@jelbourn jelbourn merged commit e2c7e1a into angular:master Jun 29, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement G This is is related to a Google internal issue target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants