Commit b3279b71d9c3c39c238f390617654fcb6d2ac006
1 parent
902a2cf5
fix select
Showing
2 changed files
with
14 additions
and
5 deletions
Show diff stats
src/components/select/functional-options.vue
... | ... | @@ -18,11 +18,17 @@ |
18 | 18 | }, |
19 | 19 | }, |
20 | 20 | functional: true, |
21 | - render(h, {props, parent}){ | |
22 | - // to detect changes in the $slot children/options we do this hack | |
23 | - // so we can trigger the parents computed properties and have everything reactive | |
24 | - // although $slot.default is not | |
25 | - if (props.slotOptions !== parent.$slots.default) props.slotUpdateHook(); | |
21 | + render(h, {props, parent}) { | |
22 | + // In order to response data changes,i do this hack. #4372 | |
23 | + if(props.slotOptions.length > 0) { | |
24 | + for(let i in props.slotOptions) { | |
25 | + if(props.slotOptions[i].key !== parent.$slots.default[i].key) { | |
26 | + props.slotUpdateHook(); | |
27 | + break; | |
28 | + } | |
29 | + } | |
30 | + } | |
31 | + if(props.slotOptions && parent.$slots.default && props.slotOptions.length !== parent.$slots.default.length) props.slotUpdateHook(); | |
26 | 32 | return props.options; |
27 | 33 | } |
28 | 34 | }; | ... | ... |
src/components/select/select.vue
... | ... | @@ -635,6 +635,9 @@ |
635 | 635 | }, |
636 | 636 | updateSlotOptions(){ |
637 | 637 | this.slotOptions = this.$slots.default; |
638 | + // #4372 issue, i find that this.query's value affects the judgment of the validateOption method. | |
639 | + this.query = ''; | |
640 | + this.focusIndex = -1; | |
638 | 641 | }, |
639 | 642 | checkUpdateStatus() { |
640 | 643 | if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) { | ... | ... |