From 52cfcd662b78ca2f550c00c35686920dcc13d1b8 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Fri, 11 May 2018 10:37:01 +0200 Subject: [PATCH] Keep last selected option index --- src/components/select/select.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 39928952..18728944 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -446,7 +446,6 @@ if (this.disabled || this.autoComplete) { return false; } - this.focusIndex = -1; this.visible = typeof force !== 'undefined' ? force : !this.visible; if (this.visible){ @@ -571,6 +570,11 @@ 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());