Commit c6de66168c9b04f30a4235af203deb7c0f48a704
Committed by
GitHub
Merge pull request #5163 from RookieZoe/2.0-fix-#5150
fix #5150
Showing
2 changed files
with
16 additions
and
2 deletions
Show diff stats
examples/routers/auto-complete.vue
src/components/select/select.vue
| ... | ... | @@ -635,7 +635,21 @@ |
| 635 | 635 | }, ANIMATION_TIMEOUT); |
| 636 | 636 | }, |
| 637 | 637 | onQueryChange(query) { |
| 638 | - if (query.length > 0 && query !== this.query) this.visible = true; | |
| 638 | + if (query.length > 0 && query !== this.query) { | |
| 639 | + // in 'AutoComplete', when set an initial value asynchronously, | |
| 640 | + // the 'dropdown list' should be stay hidden. | |
| 641 | + // [issue #5150] | |
| 642 | + if (this.autoComplete) { | |
| 643 | + let isInputFocused = | |
| 644 | + document.hasFocus && | |
| 645 | + document.hasFocus() && | |
| 646 | + document.activeElement === this.$el.querySelector('input'); | |
| 647 | + this.visible = isInputFocused; | |
| 648 | + } else { | |
| 649 | + this.visible = true; | |
| 650 | + } | |
| 651 | + } | |
| 652 | + | |
| 639 | 653 | this.query = query; |
| 640 | 654 | this.unchangedQuery = this.visible; |
| 641 | 655 | this.filterQueryChange = true; | ... | ... |