Commit c6de66168c9b04f30a4235af203deb7c0f48a704

Authored by Aresn
Committed by GitHub
2 parents de361437 215986ff

Merge pull request #5163 from RookieZoe/2.0-fix-#5150

fix #5150
examples/routers/auto-complete.vue
@@ -37,4 +37,4 @@ @@ -37,4 +37,4 @@
37 } 37 }
38 } 38 }
39 }; 39 };
40 -</script>  
41 \ No newline at end of file 40 \ No newline at end of file
  41 +</script>
src/components/select/select.vue
@@ -635,7 +635,21 @@ @@ -635,7 +635,21 @@
635 }, ANIMATION_TIMEOUT); 635 }, ANIMATION_TIMEOUT);
636 }, 636 },
637 onQueryChange(query) { 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 this.query = query; 653 this.query = query;
640 this.unchangedQuery = this.visible; 654 this.unchangedQuery = this.visible;
641 this.filterQueryChange = true; 655 this.filterQueryChange = true;