Commit 207199457b43419c8b9398518b50ba3a1d3e2fd3
Committed by
GitHub

1 parent
5d076fc5
Revert "Fix select"
Showing
2 changed files
with
12 additions
and
16 deletions
Show diff stats
src/components/select/functional-options.vue
@@ -18,17 +18,11 @@ | @@ -18,17 +18,11 @@ | ||
18 | }, | 18 | }, |
19 | }, | 19 | }, |
20 | functional: true, | 20 | functional: true, |
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(); | 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(); | ||
32 | return props.options; | 26 | return props.options; |
33 | } | 27 | } |
34 | }; | 28 | }; |
src/components/select/select.vue
@@ -356,12 +356,14 @@ | @@ -356,12 +356,14 @@ | ||
356 | }); | 356 | }); |
357 | }); | 357 | }); |
358 | } | 358 | } |
359 | + let hasDefaultSelected = slotOptions.some(option => this.query === option.key); | ||
359 | for (let option of slotOptions) { | 360 | for (let option of slotOptions) { |
360 | 361 | ||
361 | const cOptions = option.componentOptions; | 362 | const cOptions = option.componentOptions; |
362 | if (!cOptions) continue; | 363 | if (!cOptions) continue; |
363 | if (cOptions.tag.match(optionGroupRegexp)){ | 364 | if (cOptions.tag.match(optionGroupRegexp)){ |
364 | let children = cOptions.children; | 365 | let children = cOptions.children; |
366 | + | ||
365 | // remove filtered children | 367 | // remove filtered children |
366 | if (this.filterable){ | 368 | if (this.filterable){ |
367 | children = children.filter( | 369 | children = children.filter( |
@@ -378,8 +380,11 @@ | @@ -378,8 +380,11 @@ | ||
378 | if (cOptions.children.length > 0) selectOptions.push({...option}); | 380 | if (cOptions.children.length > 0) selectOptions.push({...option}); |
379 | } else { | 381 | } else { |
380 | // ignore option if not passing filter | 382 | // ignore option if not passing filter |
381 | - const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option; | ||
382 | - if (!optionPassesFilter) continue; | 383 | + if (!hasDefaultSelected) { |
384 | + const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option; | ||
385 | + if (!optionPassesFilter) continue; | ||
386 | + } | ||
387 | + | ||
383 | optionCounter = optionCounter + 1; | 388 | optionCounter = optionCounter + 1; |
384 | selectOptions.push(this.processOption(option, selectedValues, optionCounter === currentIndex)); | 389 | selectOptions.push(this.processOption(option, selectedValues, optionCounter === currentIndex)); |
385 | } | 390 | } |
@@ -636,9 +641,6 @@ | @@ -636,9 +641,6 @@ | ||
636 | }, | 641 | }, |
637 | updateSlotOptions(){ | 642 | updateSlotOptions(){ |
638 | this.slotOptions = this.$slots.default; | 643 | this.slotOptions = this.$slots.default; |
639 | - // #4372 issue, i find that this.query's value affects the judgment of the validateOption method. | ||
640 | - this.query = ''; | ||
641 | - this.focusIndex = -1; | ||
642 | }, | 644 | }, |
643 | checkUpdateStatus() { | 645 | checkUpdateStatus() { |
644 | if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) { | 646 | if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) { |