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 1/2] =?UTF-8?q?fix:=20element=20cascader=20=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E6=93=8D=E4=BD=9Coptions=E5=85=A8=E9=87=8F=E6=9B=B4?= =?UTF-8?q?=E6=96=B0nodes=20=E6=90=9C=E7=B4=A2suggestions=E5=A4=B1?= =?UTF-8?q?=E5=8E=BB=E5=93=8D=E5=BA=94=E5=BC=8F=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=EF=BC=9A=E6=89=8B=E5=8A=A8=E8=AE=B0=E5=BD=95=E4=B8=8A=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E6=90=9C=E7=B4=A2=20=E9=87=8D=E6=96=B0=E7=BB=91?= =?UTF-8?q?=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 0aad54baf1e..6b0ca064503 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 || ' ' } }, From 07e36bf80ac18379cb5e8fd725a04b75278241d4 Mon Sep 17 00:00:00 2001 From: BernardZheng <1329146797@qq.com> Date: Tue, 9 Jul 2024 09:09:55 +0800 Subject: [PATCH 2/2] fix: filterMethod --- packages/cascader/src/cascader.vue | 297 ++++++++++++++++------------- 1 file changed, 166 insertions(+), 131 deletions(-) diff --git a/packages/cascader/src/cascader.vue b/packages/cascader/src/cascader.vue index 6b0ca064503..718af939a25 100644 --- a/packages/cascader/src/cascader.vue +++ b/packages/cascader/src/cascader.vue @@ -4,14 +4,14 @@ :class="[ 'el-cascader', realSize && `el-cascader--${realSize}`, - { 'is-disabled': isDisabled } + { 'is-disabled': isDisabled }, ]" v-clickoutside="() => toggleDropDownVisible(false)" @mouseenter="inputHover = true" @mouseleave="inputHover = false" @click="() => toggleDropDownVisible(readonly ? undefined : true)" - @keydown="handleKeyDown"> - + @keydown="handleKeyDown" + > + @input="handleInput" + > @@ -51,7 +54,8 @@ :hit="tag.hitState" :closable="tag.closable" disable-transitions - @close="deleteTag(tag)"> + @close="deleteTag(tag)" + > {{ tag.text }} + @keydown.delete="handleDelete" + />
+ :class="['el-popper', 'el-cascader__dropdown', popperClass]" + > + @close="toggleDropDownVisible(false)" + > + @keydown.native="handleSuggestionKeyDown" + > -
  • {{ t('el.cascader.noMatch') }}
  • +
  • + {{ t("el.cascader.noMatch") }} +
  • @@ -112,69 +123,72 @@ -