From b6ffb321bcc38c339fbbee0d5ebd7a1f2b7bcaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E9=BE=99?= Date: Mon, 8 Jul 2024 14:54:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20element=20cascader=20=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E6=93=8D=E4=BD=9Coptions=E5=85=A8=E9=87=8F=E6=9B=B4=E6=96=B0no?= =?UTF-8?q?des=20=E6=90=9C=E7=B4=A2suggestions=E5=A4=B1=E5=8E=BB=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=BC=8F=E9=97=AE=E9=A2=98=20=EF=BC=9A=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E8=AE=B0=E5=BD=95=E4=B8=8A=E4=B8=80=E6=AC=A1=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=20=E9=87=8D=E6=96=B0=E7=BB=91=E5=AE=9A=E6=96=B0nodes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cascader/src/cascader.vue | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/cascader/src/cascader.vue b/packages/cascader/src/cascader.vue index 0aad54baf..6b0ca0645 100644 --- a/packages/cascader/src/cascader.vue +++ b/packages/cascader/src/cascader.vue @@ -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 || ' ' } },