fix: element cascader 手动操作options全量更新nodes 搜索suggestions失去响应式问题 :手动记录上一次搜索 重新绑定新nodes

pull/22918/head
郑龙 2024-07-08 14:54:24 +08:00
parent c345bb453b
commit b6ffb321bc
1 changed files with 18 additions and 1 deletions

View File

@ -235,6 +235,7 @@ export default {
checkedValue: this.value,
inputHover: false,
inputValue: null,
lastInputValue: null, // Last effective inputValue
presentText: null,
presentTags: [],
checkedNodes: [],
@ -328,7 +329,18 @@ export default {
},
options: {
handler: function() {
this.$nextTick(this.computePresentContent);
this.$nextTick(() => {
this.computePresentContent()
if(this.filtering) {
this.suggestions = this.panel.getFlattedNodes(this.leafOnly)
.filter(node => {
if (node.isDisabled) return false;
node.text = node.getText(this.showAllLevels, this.separator) || '';
return filterMethod(node, this.lastInputValue);
});
}
});
},
deep: true
},
@ -342,6 +354,11 @@ export default {
},
filtering(val) {
this.$nextTick(this.updatePopper);
},
inputValue(newVal, oldVal) {
const oldValue = oldVal && oldVal !== ' ' ? oldVal : this.lastInputValue
const newValue = newVal && newVal !== ' ' ? newVal : false
this.lastInputValue = newValue || oldValue || ' '
}
},