fix(file-tree): 使用完整节点路径隔离折叠状态 - #75
Merged
wang-kaopu merged 3 commits intoAug 28, 2026
Merged
Conversation
wang-kaopu
force-pushed
the
fix/file-tree-collapse-key
branch
from
August 28, 2026 13:11
738d582 to
f25e349
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
file-tree之前使用depth-index作为目录折叠状态 key。不同父目录下,只要子目录处于相同 depth / index,就会共享同一个 key,导致折叠其中一个目录时另一个目录也被错误折叠。
修复
递归渲染时传递完整 occurrence path,例如:
0/01/0折叠状态和 React key 都使用完整路径,而不是只使用局部 depth / index。
测试
新增两个不同父目录、但子目录拥有相同局部 depth/index 的回归用例,确认它们可以独立展开和折叠。
验证
提交 PR 前已执行:
pnpm run checklib/产物