Commit b6c069ca9d58408fd5ec2979f9f9878fdd4fea05
1 parent
45bcc14d
reset query if options are removed
Showing
1 changed file
with
12 additions
and
7 deletions
Show diff stats
src/components/select/select.vue
@@ -282,10 +282,11 @@ | @@ -282,10 +282,11 @@ | ||
282 | const selectedValues = this.values.map(({value}) => value); | 282 | const selectedValues = this.values.map(({value}) => value); |
283 | for (let option of (this.slotOptions || [])) { | 283 | for (let option of (this.slotOptions || [])) { |
284 | 284 | ||
285 | - if (!option.componentOptions) continue; | 285 | + const cOptions = option.componentOptions; |
286 | + if (!cOptions) continue; | ||
286 | 287 | ||
287 | - if (option.componentOptions.tag.match(optionGroupRegexp)){ | ||
288 | - let children = option.componentOptions.children; | 288 | + if (cOptions.tag.match(optionGroupRegexp)){ |
289 | + let children = cOptions.children; | ||
289 | 290 | ||
290 | // remove filtered children | 291 | // remove filtered children |
291 | if (this.filterable){ | 292 | if (this.filterable){ |
@@ -294,16 +295,16 @@ | @@ -294,16 +295,16 @@ | ||
294 | ); | 295 | ); |
295 | } | 296 | } |
296 | 297 | ||
297 | - option.componentOptions.children = children.map(opt => { | 298 | + cOptions.children = children.map(opt => { |
298 | optionCounter = optionCounter + 1; | 299 | optionCounter = optionCounter + 1; |
299 | return this.processOption(opt, selectedValues, optionCounter === currentIndex); | 300 | return this.processOption(opt, selectedValues, optionCounter === currentIndex); |
300 | }); | 301 | }); |
301 | 302 | ||
302 | // keep the group if it still has children | 303 | // keep the group if it still has children |
303 | - if (option.componentOptions.children.length > 0) selectOptions.push({...option}); | 304 | + if (cOptions.children.length > 0) selectOptions.push({...option}); |
304 | } else { | 305 | } else { |
305 | // ignore option if not passing filter | 306 | // ignore option if not passing filter |
306 | - const optionPassesFilter = this.filterable ? this.validateOption(option.componentOptions) : option; | 307 | + const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option; |
307 | if (!optionPassesFilter) continue; | 308 | if (!optionPassesFilter) continue; |
308 | 309 | ||
309 | optionCounter = optionCounter + 1; | 310 | optionCounter = optionCounter + 1; |
@@ -614,11 +615,15 @@ | @@ -614,11 +615,15 @@ | ||
614 | dropVisible(open){ | 615 | dropVisible(open){ |
615 | this.broadcast('Drop', open ? 'on-update-popper' : 'on-destroy-popper'); | 616 | this.broadcast('Drop', open ? 'on-update-popper' : 'on-destroy-popper'); |
616 | }, | 617 | }, |
617 | - selectOptions(){ | 618 | + selectOptions(options){ |
618 | if (this.hasExpectedValue){ | 619 | if (this.hasExpectedValue){ |
619 | this.values = this.values.map(this.getOptionData); | 620 | this.values = this.values.map(this.getOptionData); |
620 | this.hasExpectedValue = false; | 621 | this.hasExpectedValue = false; |
621 | } | 622 | } |
623 | + | ||
624 | + if (options.length === 0){ | ||
625 | + this.query = ''; | ||
626 | + } | ||
622 | } | 627 | } |
623 | } | 628 | } |
624 | }; | 629 | }; |