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

fix(tree): cannot expand #6725 #6727

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## NEXT_VERSION

### Fixes

- Fix: When the 'expanded keys' attribute of' n-tree 'contains a' key 'that does not exist in the tree, the component cannot expand

## 2.41.0

`2025-01-05`
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## NEXT_VERSION

### Fixes

- 修复 `n-tree` 的 `expanded-keys` 属性包含不存在于树中的 `key` 时,组件无法展开

## 2.41.0

`2025-01-05`
Expand Down
8 changes: 4 additions & 4 deletions src/tree/src/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ export function createTreeMateOptions<T>(
): TreeMateOptions<T, T, T> {
const settledGetChildren: GetChildren
= getChildren
|| ((node: T) => {
return (node as any)[childrenField]
})
|| ((node: T) => {
return (node as any)[childrenField]
})
return {
getIsGroup() {
return false
Expand Down Expand Up @@ -770,7 +770,6 @@ export default defineComponent({
)
}
}
aipRef.value = true
afNodesRef.value
= displayTreeMateRef.value.getFlattenedNodes(baseExpandedKeys)
if (addedKey !== null) {
Expand All @@ -782,6 +781,7 @@ export default defineComponent({
.children
// sometimes user will pass leaf keys in
if (children) {
aipRef.value = true
const expandedChildren = flatten(children, value)
afNodesRef.value.splice(expandedNodeIndex + 1, 0, {
__motion: true,
Expand Down