Skip to content

feat(tree): support array of data as children in nested tree #10886

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 1 commit into from
Jun 28, 2018

Conversation

tinayuangao
Copy link
Contributor

No description provided.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Apr 16, 2018
@tinayuangao tinayuangao force-pushed the tree-nested-children branch from a7b0c2d to f1b20ac Compare May 11, 2018 18:41
@tinayuangao tinayuangao added target: minor This PR is targeted for the next minor release pr: needs review labels May 11, 2018
@tinayuangao tinayuangao requested review from crisbeto and jelbourn May 11, 2018 18:41
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

  • Are there any examples that could be simplified with this?
  • Should the docs be updated anywhere based on this?

if (Array.isArray(childrenNodes)) {
this._setRoleFromChildren(childrenNodes as T[]);
} else if (childrenNodes instanceof Observable) {
childrenNodes.pipe(takeUntil(this._destroyed)).subscribe(this._setRoleFromChildren);
Copy link
Member

Choose a reason for hiding this comment

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

You might be getting an incorrect this inside _setRoleFromChildren by passing in the function like this.

if (Array.isArray(childrenNodes)) {
childrenNodes.forEach((child: T) => this._getDescendants(descendants, child));
} else if (childrenNodes instanceof Observable) {
childrenNodes.pipe(take(1)).subscribe(children => {
Copy link
Member

Choose a reason for hiding this comment

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

Since this is being done recursively and childrenNodes can be async, couldn't this potentially lead to some race conditions?

childrenNodes.forEach((child: T) => this._getDescendants(descendants, child));
} else if (childrenNodes instanceof Observable) {
childrenNodes.pipe(take(1)).subscribe(children => {
if (children && children.length > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

AFAIK forEach will handle the case where children.length === 0 for you.


treeControl.expandAll();

const totalNumber = numNodes + numNodes * numChildren
Copy link
Member

Choose a reason for hiding this comment

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

Consider adding parentheses around some of these to make it easier to follow.

@ngbot
Copy link

ngbot bot commented Jun 20, 2018

Hi @tinayuangao! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

1 similar comment
@ngbot
Copy link

ngbot bot commented Jun 20, 2018

Hi @tinayuangao! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@tinayuangao tinayuangao force-pushed the tree-nested-children branch 2 times, most recently from 0630fe6 to 27a2b5a Compare June 26, 2018 18:39
@tinayuangao tinayuangao force-pushed the tree-nested-children branch from 27a2b5a to 1b14996 Compare June 27, 2018 18:08
@tinayuangao
Copy link
Contributor Author

@jelbourn Updated example and docs. Please take a look. Thanks!

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jun 27, 2018
@ngbot
Copy link

ngbot bot commented Jun 27, 2018

I see that you just added the pr: merge ready label, but the following checks are still failing:
    failure status "ci/circleci: build" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@josephperrott josephperrott merged commit 825d35c into angular:master Jun 28, 2018
crisbeto added a commit to crisbeto/material2 that referenced this pull request Dec 17, 2018
Gracefully handles nodes whose children are set to null. This seems to be something that we used to handle until a regression from angular#10886.

Fixes angular#14545.
jelbourn pushed a commit that referenced this pull request Dec 18, 2018
Gracefully handles nodes whose children are set to null. This seems to be something that we used to handle until a regression from #10886.

Fixes #14545.
josephperrott pushed a commit to josephperrott/components that referenced this pull request Jan 14, 2019
Gracefully handles nodes whose children are set to null. This seems to be something that we used to handle until a regression from angular#10886.

Fixes angular#14545.
@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 Sep 9, 2019
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 target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants