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

Collapse children of collapsed node possible? #276

Open
mike-ward opened this issue Jun 16, 2017 · 3 comments
Open

Collapse children of collapsed node possible? #276

mike-ward opened this issue Jun 16, 2017 · 3 comments

Comments

@mike-ward
Copy link

Open a node several levels deep. Then collapse the first node opened. The nodes expanded under the first node are still expanded. You can see this by reopening a node. Is there a way to collapse the children of the collapsed node? If not maybe add a configuration option?

@yoavaa
Copy link
Contributor

yoavaa commented Jun 20, 2017

the list of expanded nodes is managed in the expanded nodes array. Just remove from it what you do not wanna have there.

I did not implement the logic to do so automatically.

Having such a configuration option sounds nice, if you create a PR (with tests) will merge it.

@mike-ward
Copy link
Author

I looked at the array before posting this issue. I didn't see a way to determine if a node was a child of another (no parent reference). Maybe there's something I don't understand about the structure.

@mike-ward
Copy link
Author

mike-ward commented Jun 21, 2017

For what it's worth I was able to write a function to do this. Hooked it into the on-toggle-node event.

function collapseNode(node): void {
    scope.expandedNodes = scope.expandedNodes.filter(en => isNotChild(node, en));
}

function isNotChild(node, en): boolean {
    if (!node.children) return true;
    return node.children.every(n => n !== en && isNotChild(n, en));
}

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

No branches or pull requests

2 participants