Commit 2d1b86d4d7a08ccb0c50e140f067ad476c2cce02
Committed by
GitHub
Merge pull request #3753 from SergioCrisostomo/autocomplete-patches
Change logic for hiding AutoComplete panel
Showing
2 changed files
with
4 additions
and
6 deletions
Show diff stats
src/components/auto-complete/auto-complete.vue
| @@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
| 8 | :placeholder="placeholder" | 8 | :placeholder="placeholder" |
| 9 | :size="size" | 9 | :size="size" |
| 10 | :placement="placement" | 10 | :placement="placement" |
| 11 | + :value="currentValue" | ||
| 11 | filterable | 12 | filterable |
| 12 | remote | 13 | remote |
| 13 | auto-complete | 14 | auto-complete |
| @@ -146,22 +147,19 @@ | @@ -146,22 +147,19 @@ | ||
| 146 | }, | 147 | }, |
| 147 | handleChange (val) { | 148 | handleChange (val) { |
| 148 | this.currentValue = val; | 149 | this.currentValue = val; |
| 149 | - this.$refs.select.model = val; | ||
| 150 | this.$refs.input.blur(); | 150 | this.$refs.input.blur(); |
| 151 | this.$emit('on-select', val); | 151 | this.$emit('on-select', val); |
| 152 | }, | 152 | }, |
| 153 | handleFocus (event) { | 153 | handleFocus (event) { |
| 154 | - this.$refs.select.visible = true; | ||
| 155 | this.$emit('on-focus', event); | 154 | this.$emit('on-focus', event); |
| 156 | }, | 155 | }, |
| 157 | handleBlur (event) { | 156 | handleBlur (event) { |
| 158 | - this.$refs.select.visible = false; | ||
| 159 | this.$emit('on-blur', event); | 157 | this.$emit('on-blur', event); |
| 160 | }, | 158 | }, |
| 161 | handleClear () { | 159 | handleClear () { |
| 162 | if (!this.clearable) return; | 160 | if (!this.clearable) return; |
| 163 | this.currentValue = ''; | 161 | this.currentValue = ''; |
| 164 | - this.$refs.select.model = ''; | 162 | + this.$refs.select.reset(); |
| 165 | } | 163 | } |
| 166 | } | 164 | } |
| 167 | }; | 165 | }; |
src/components/select/select.vue
| @@ -346,7 +346,7 @@ | @@ -346,7 +346,7 @@ | ||
| 346 | const selectedSlotOption = autoCompleteOptions[currentIndex]; | 346 | const selectedSlotOption = autoCompleteOptions[currentIndex]; |
| 347 | 347 | ||
| 348 | return slotOptions.map(node => { | 348 | return slotOptions.map(node => { |
| 349 | - if (node === selectedSlotOption) return applyProp(node, 'isFocused', true); | 349 | + if (node === selectedSlotOption || getNestedProperty(node, 'componentOptions.propsData.value') === this.value) return applyProp(node, 'isFocused', true); |
| 350 | return copyChildren(node, (child) => { | 350 | return copyChildren(node, (child) => { |
| 351 | if (child !== selectedSlotOption) return child; | 351 | if (child !== selectedSlotOption) return child; |
| 352 | return applyProp(child, 'isFocused', true); | 352 | return applyProp(child, 'isFocused', true); |
| @@ -467,7 +467,7 @@ | @@ -467,7 +467,7 @@ | ||
| 467 | }, | 467 | }, |
| 468 | 468 | ||
| 469 | toggleMenu (e, force) { | 469 | toggleMenu (e, force) { |
| 470 | - if (this.disabled || this.autoComplete) { | 470 | + if (this.disabled) { |
| 471 | return false; | 471 | return false; |
| 472 | } | 472 | } |
| 473 | 473 |