fix select

This commit is contained in:
oyv1cent 2018-08-30 00:28:32 +08:00
parent 902a2cf595
commit b3279b71d9
2 changed files with 14 additions and 5 deletions

View file

@ -18,11 +18,17 @@
}, },
}, },
functional: true, functional: true,
render(h, {props, parent}){ render(h, {props, parent}) {
// to detect changes in the $slot children/options we do this hack // In order to response data changes,i do this hack. #4372
// so we can trigger the parents computed properties and have everything reactive if(props.slotOptions.length > 0) {
// although $slot.default is not for(let i in props.slotOptions) {
if (props.slotOptions !== parent.$slots.default) props.slotUpdateHook(); 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; return props.options;
} }
}; };

View file

@ -635,6 +635,9 @@
}, },
updateSlotOptions(){ updateSlotOptions(){
this.slotOptions = this.$slots.default; 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() { checkUpdateStatus() {
if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) { if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) {