Commit 52cfcd662b78ca2f550c00c35686920dcc13d1b8

Authored by Sergio Crisostomo
1 parent 1376a01a

Keep last selected option index

Showing 1 changed file with 5 additions and 1 deletions   Show diff stats
src/components/select/select.vue
@@ -446,7 +446,6 @@ @@ -446,7 +446,6 @@
446 if (this.disabled || this.autoComplete) { 446 if (this.disabled || this.autoComplete) {
447 return false; 447 return false;
448 } 448 }
449 - this.focusIndex = -1;  
450 449
451 this.visible = typeof force !== 'undefined' ? force : !this.visible; 450 this.visible = typeof force !== 'undefined' ? force : !this.visible;
452 if (this.visible){ 451 if (this.visible){
@@ -571,6 +570,11 @@ @@ -571,6 +570,11 @@
571 this.hideMenu(); 570 this.hideMenu();
572 } 571 }
573 572
  573 + this.focusIndex = this.flatOptions.findIndex((opt) => {
  574 + if (!opt || !opt.componentOptions) return false;
  575 + return opt.componentOptions.propsData.value === option.value;
  576 + });
  577 +
574 if (this.filterable){ 578 if (this.filterable){
575 const inputField = this.$el.querySelector('input[type="text"]'); 579 const inputField = this.$el.querySelector('input[type="text"]');
576 if (!this.autoComplete) this.$nextTick(() => inputField.focus()); 580 if (!this.autoComplete) this.$nextTick(() => inputField.focus());