From 33c826ec166c2efbb40aef493f4810baf2214eb2 Mon Sep 17 00:00:00 2001 From: Rookie_Zoe Date: Mon, 7 Jan 2019 12:24:48 +0800 Subject: [PATCH] fix #5150 --- examples/routers/auto-complete.vue | 73 +++++++++++++++++++++++++++++++++++++------------------------------------ src/components/select/select.vue | 13 ++++++++++++- 2 files changed, 49 insertions(+), 37 deletions(-) diff --git a/examples/routers/auto-complete.vue b/examples/routers/auto-complete.vue index 0ecd673..6d3cb96 100644 --- a/examples/routers/auto-complete.vue +++ b/examples/routers/auto-complete.vue @@ -1,40 +1,41 @@ \ No newline at end of file + }, + methods: {}, + created() { + setTimeout(() => { + this.value = "1.0.0.5"; + this.data = [ + "12412515", + "123444", + "12355", + "12345", + "12312", + "1234", + "123", + "111", + "5.2.3.4", + "1.2.3.4", + "1.2.3.4.5", + "1.2.3.4.5.6", + "1.2.3.4.5.6.7", + "1.0.0.8", + "1.0.0.5", + "whb-03" + ]; + // this.disabled = true; + }, 1000); + } +}; + diff --git a/src/components/select/select.vue b/src/components/select/select.vue index d446a8a..8a7752a 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -635,7 +635,18 @@ }, ANIMATION_TIMEOUT); }, onQueryChange(query) { - if (query.length > 0 && query !== this.query) this.visible = true; + if (query.length > 0 && query !== this.query) { + // in 'AutoComplete', when set an initial value asynchronously, + // the 'dropdown list' should be stay hidden. + // [issue #5150] + let isInputFocused = + document.hasFocus && + document.hasFocus() && + document.activeElement === this.$el.querySelector('input'); + + this.visible = isInputFocused; + } + this.query = query; this.unchangedQuery = this.visible; this.filterQueryChange = true; -- libgit2 0.21.4