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

New data set ignores initialDepth #47

Closed
RohanDamani opened this issue Oct 27, 2017 · 4 comments
Closed

New data set ignores initialDepth #47

RohanDamani opened this issue Oct 27, 2017 · 4 comments

Comments

@RohanDamani
Copy link
Contributor

If the data set changes (ie user filters), the tree rerenders with all nodes open.

I am using a dynamic initial depth prop to maintain which level is open, and I would like the tree to reread the initial depth prop as the data set changes to stay at the current highest level open.

As the user clicks a node, I will pass the depth to state. In conjunction with #46 the other nodes will close, so the clicked node will be at the highest level. The user can filter data, and the tree will render new nodes to the same level.

@francisngo
Copy link

@RohanDamani Could you paste/share your code for this?

@tokarskyibogdan
Copy link

Did someone find solution?
@francisngo steps to reproduce

  • create react component with react-d3-tree element
  • when the component receives a new tree data the tree is going to show every node as opened

@bkrem
Copy link
Owner

bkrem commented Jan 15, 2020

Apologies it's taken me so long to address this issue properly.

I'm dedicating myself for the next few weeks to resolving long-standing issues that are still shippable as part of v1 (like this one), as well as shipping a long-overdue v2 with a typescript-first, less opinionated, and more flexible public API.

I will update this thread once this issue is resolved for the updating data case, either as one of the last v1 patches, or as part of v2.

@bkrem bkrem removed this from the v1.7.0 milestone Jan 16, 2020
@bkrem bkrem added the v2.0.0 label Mar 16, 2020
bkrem added a commit that referenced this issue Dec 19, 2020
After the initial render with `initialDepth` set, clicking a node which
contained multiple sublevels would expand the entire subtree.

This was due to an unnecessary special case in the tree generation step,
which meant not all possible child nodes could be collapsed when the
tree was generated.
@bkrem
Copy link
Owner

bkrem commented Dec 29, 2020

Fixed in v1.17.1 and by extension in v2.0.0.

If you're able to, I'd highly recommend checking out v2, since it's a major overhaul of the docs, the library's internals (Typescript-first), and the API's flexibility (e.g. renderCustomNodeElement).

Going forward, v1 is considered deprecated and will only be updated for necessary patch releases. You can still find the old docs on the v1 branch.

I've added regression tests for this bug, but if you do encounter it again please open another issue.

Apologies for the long wait with this annoying bug 🙏 v2 should've been done early this year, but I had to put unpaid projects (including open-source) aside for most of 2020 due to some "unexpected global events".

@bkrem bkrem closed this as completed Dec 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants