2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-05-17 02:29:37 +03:00

feat: set pointer to most recent selected option on open (#1574)

Co-authored-by: Jeff Sagal <sagalbot@gmail.com>
This commit is contained in:
Mehdi ghasemi
2022-02-17 23:32:24 +03:30
committed by GitHub
parent 475b75d0fe
commit 5c09d6ffba
3 changed files with 58 additions and 3 deletions
+22
View File
@@ -14,6 +14,16 @@ export default {
}
}
},
open(open) {
if (open) {
this.typeAheadToLastSelected()
}
},
selectedValue() {
if (this.open) {
this.typeAheadToLastSelected()
}
},
},
methods: {
@@ -61,5 +71,17 @@ export default {
this.select(typeAheadOption)
}
},
/**
* Moves the pointer to the last selected option.
*/
typeAheadToLastSelected() {
this.typeAheadPointer =
this.selectedValue.length !== 0
? this.filteredOptions.indexOf(
this.selectedValue[this.selectedValue.length - 1]
)
: -1
},
},
}