From 902a2cf595a1df2d09eff9fcb41f637e88ff5919 Mon Sep 17 00:00:00 2001 From: vincentfintend Date: Mon, 27 Aug 2018 16:08:13 +0800 Subject: [PATCH 1/2] fix --- src/components/select/select.vue | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 306376d0..012fb939 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -355,14 +355,12 @@ }); }); } - let hasDefaultSelected = slotOptions.some(option => this.query === option.key); for (let option of slotOptions) { const cOptions = option.componentOptions; if (!cOptions) continue; if (cOptions.tag.match(optionGroupRegexp)){ let children = cOptions.children; - // remove filtered children if (this.filterable){ children = children.filter( @@ -379,11 +377,8 @@ if (cOptions.children.length > 0) selectOptions.push({...option}); } else { // ignore option if not passing filter - if (!hasDefaultSelected) { - const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option; - if (!optionPassesFilter) continue; - } - + const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option; + if (!optionPassesFilter) continue; optionCounter = optionCounter + 1; selectOptions.push(this.processOption(option, selectedValues, optionCounter === currentIndex)); } From b3279b71d9c3c39c238f390617654fcb6d2ac006 Mon Sep 17 00:00:00 2001 From: oyv1cent <641027967@qq.com> Date: Thu, 30 Aug 2018 00:28:32 +0800 Subject: [PATCH 2/2] fix select --- src/components/select/functional-options.vue | 16 +++++++++++----- src/components/select/select.vue | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/select/functional-options.vue b/src/components/select/functional-options.vue index a3197096..39783bd7 100644 --- a/src/components/select/functional-options.vue +++ b/src/components/select/functional-options.vue @@ -18,11 +18,17 @@ }, }, functional: true, - render(h, {props, parent}){ - // to detect changes in the $slot children/options we do this hack - // so we can trigger the parents computed properties and have everything reactive - // although $slot.default is not - if (props.slotOptions !== parent.$slots.default) props.slotUpdateHook(); + render(h, {props, parent}) { + // In order to response data changes,i do this hack. #4372 + if(props.slotOptions.length > 0) { + for(let i in props.slotOptions) { + if(props.slotOptions[i].key !== parent.$slots.default[i].key) { + props.slotUpdateHook(); + break; + } + } + } + if(props.slotOptions && parent.$slots.default && props.slotOptions.length !== parent.$slots.default.length) props.slotUpdateHook(); return props.options; } }; diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 012fb939..52f5d13a 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -635,6 +635,9 @@ }, updateSlotOptions(){ this.slotOptions = this.$slots.default; + // #4372 issue, i find that this.query's value affects the judgment of the validateOption method. + this.query = ''; + this.focusIndex = -1; }, checkUpdateStatus() { if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) {