Skip to content

Commit 5917df2

Browse files
authored
fix(tree-select): After deleting the last child node of the parent node, another child node is selected. #3508 #3586 (#4047)
1 parent b7783ae commit 5917df2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

components/vc-tree-select/src/Select.jsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,12 +874,24 @@ const Select = defineComponent({
874874
},
875875

876876
onSearchInputKeyDown(event) {
877-
const { _searchValue: searchValue, _valueList: valueList } = this.$data;
877+
const { _searchValue: searchValue, _valueList: valueList, _valueEntities: valueEntities } = this.$data;
878878

879879
const { keyCode } = event;
880880

881881
if (KeyCode.BACKSPACE === keyCode && this.isMultiple() && !searchValue && valueList.length) {
882-
const lastValue = valueList[valueList.length - 1].value;
882+
let lastValue = valueList[valueList.length - 1].value;
883+
const { treeCheckStrictly } = this.$props;
884+
if(!treeCheckStrictly) {
885+
let cur = valueEntities[lastValue];
886+
while(cur) {
887+
if(valueList.some(j => j.value === cur.value)) {
888+
lastValue = cur.value;
889+
cur = cur.parent;
890+
}else{
891+
cur = null
892+
}
893+
}
894+
}
883895
this.onMultipleSelectorRemove(event, lastValue);
884896
}
885897
},

0 commit comments

Comments
 (0)