Skip to content

Commit c767abb

Browse files
committed
refactor: enhance node click handling in Classification component
- Updated nodeClickHandler to toggle node selection based on current checked state, improving user interaction. - Added props to disable checking on click for nodes and leaves, enhancing control over tree behavior.
1 parent 71e8471 commit c767abb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/component/src/Classification.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,15 @@ export default {
150150
this.emitCheckedNodes()
151151
},
152152
nodeClickHandler(data, node) {
153-
this.$refs.tree?.setCheckedKeys([data.id], true)
153+
let checkedNodes = this.$refs.tree.getCheckedKeys() || []
154+
155+
if (checkedNodes.includes(data.id)) {
156+
this.$refs.tree?.setChecked(data.id, false)
157+
} else {
158+
this.$refs.tree?.setCheckedKeys([data.id], true)
159+
}
160+
161+
this.emitCheckedNodes()
154162
},
155163
emitCheckedNodes() {
156164
let checkedNodes = this.$refs.tree.getCheckedKeys() || []
@@ -539,6 +547,8 @@ export default {
539547
:filter-node-method="filterNode"
540548
:render-after-expand="false"
541549
:indent="8"
550+
:check-on-click-node="false"
551+
:check-on-click-leaf="false"
542552
@node-click="nodeClickHandler"
543553
@check="checkHandler"
544554
>

0 commit comments

Comments
 (0)