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

Tree.DirectoryTree - defaultExpandAll does not work when using treeData #19132

Closed
1 task done
pfcodes opened this issue Oct 9, 2019 · 5 comments
Closed
1 task done
Assignees

Comments

@pfcodes
Copy link

pfcodes commented Oct 9, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://codepen.io/pfcodes/pen/WNNvpOP

Steps to reproduce

Use: <Tree.DirectoryTree treeData={[]} defaultExpandAll></Tree.DirectoryTree> instead of <Tree.DirectoryTree defaultExpandAll>{TreeNode[]}</Tree.DirectoryTree>

What is expected?

All tree nodes should be expanded.

What is actually happening?

Tree nodes are not expanded.

Environment Info
antd 3.23.6
React react 16.10.2
System macOS 10.14.6
Browser Version 77.0.3865.90 (Official Build) (64-bit)

I needed to recursively create TreeNodes. The DirectoryTree component does not allow any component other than TreeNode to be used as a child. Since I could not use custom components (i.e., DirectoryNode/FileNode) that were output from a recursive function that first determines whether a node is a directory or file, I found treeData and used that instead. I noticed the bug then.

kavience pushed a commit to kavience/ant-design that referenced this issue Oct 10, 2019
@kavience
Copy link

I have find the bug and I have make a new PR in #19148, can you take a look ? @afc163

kavience pushed a commit to kavience/ant-design that referenced this issue Oct 10, 2019
kavience pushed a commit to kavience/ant-design that referenced this issue Oct 10, 2019
kavience pushed a commit to kavience/ant-design that referenced this issue Oct 10, 2019
kavience pushed a commit to kavience/ant-design that referenced this issue Oct 11, 2019
kavience pushed a commit to kavience/ant-design that referenced this issue Oct 11, 2019
kavience pushed a commit to kavience/ant-design that referenced this issue Oct 11, 2019
afc163 pushed a commit that referenced this issue Oct 12, 2019
afc163 pushed a commit that referenced this issue Oct 12, 2019
@afc163 afc163 closed this as completed Oct 12, 2019
@jeremypeters
Copy link

I'm experiencing this issue when the tree data is updated. When using defaultExpandAll={true} the tree is expanded, but when the tree data is updated, the tree collapses.

@jonathaninacio
Copy link

jonathaninacio commented Mar 25, 2021

I'm experiencing this issue when the tree data is updated. When using defaultExpandAll={true} the tree is expanded, but when the tree data is updated, the tree collapses.

I had the same problem and realize it was because all keys in treedata has changed.
New nodes are collapsed by default, only the original ones (default) are expanded. But in tree data when all keys are different from the original one, the tree is replaced with a new one (so it's not the default tree anymore).

@blazephoenix
Copy link

blazephoenix commented Jan 8, 2023

Was this resolved for v4.x?

@calllpso
Copy link

you should to add a v-if condition, after that it will work
<a-tree v-if="treeData.length>0" :defaultExpandAll="true" :tree-data="treeData" > <!-- your code --> </a-tree>

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

7 participants