From 12fe96a865e0ef4458958011b380f7ae501dd9b7 Mon Sep 17 00:00:00 2001 From: yangd Date: Sat, 15 Feb 2020 20:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Select=20=E5=9C=A8?= =?UTF-8?q?=E5=8D=95=E9=80=89=E6=90=9C=E7=B4=A2=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1=E7=82=B9=E5=87=BB=E4=BC=9A=E4=BB=A5?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E5=80=BC=E6=89=A7=E8=A1=8C=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/select/select.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 412802ea..7fb4cb47 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -662,17 +662,23 @@ } this.isFocused = true; // so we put back focus after clicking with mouse on option elements } else { - this.query = ''; + this.query = String(option.label).trim(); this.values = [option]; this.lastRemoteQuery = ''; this.hideMenu(); } + + this.focusIndex = this.flatOptions.findIndex((opt) => { + if (!opt || !opt.componentOptions) return false; + return opt.componentOptions.propsData.value === option.value; + }); + if (this.filterable){ const inputField = this.$el.querySelector('input[type="text"]'); if (!this.autoComplete) this.$nextTick(() => inputField.focus()); } + this.$emit('on-select', option); // # 4441 this.broadcast('Drop', 'on-update-popper'); - this.$emit('on-select', this.publicValue); // # 4441 setTimeout(() => { this.filterQueryChange = false; }, ANIMATION_TIMEOUT);