Skip to content

Commit

Permalink
No selection on tree node if selectionKeys prop is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Sep 19, 2024
1 parent a57c958 commit 50e04bf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/common/TreeExplorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const expandedKeys = defineModel<Record<string, boolean>>('expandedKeys')
provide('expandedKeys', expandedKeys)
const selectionKeys = defineModel<Record<string, boolean>>('selectionKeys')
provide('selectionKeys', selectionKeys)
// Tracks whether the caller has set the selectionKeys model.
const storeSelectionKeys = selectionKeys.value !== undefined
const props = defineProps<{
roots: TreeExplorerNode[]
class?: string
Expand Down Expand Up @@ -90,6 +93,9 @@ const fillNodeInfo = (node: TreeExplorerNode): RenderedTreeExplorerNode => {
}
}
const onNodeContentClick = (e: MouseEvent, node: RenderedTreeExplorerNode) => {
if (!storeSelectionKeys) {
selectionKeys.value = {}
}
if (node.handleClick) {
node.handleClick(node, e)
}
Expand Down

0 comments on commit 50e04bf

Please sign in to comment.