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:
@@ -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
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user