fix(select): auto focus option in autoUpdateModel

This makes sure that the first option gets focused
after the select is open and also if the options are changes
in cases where the options are being loaded and passed
to the select at a later point.
pull/7282/head
Jakub Michálek 2025-02-20 06:00:47 +01:00
parent d71183fcc4
commit 6d8aa45167
1 changed files with 5 additions and 2 deletions

View File

@ -686,7 +686,7 @@ export default {
setTimeout(() => {
this.autoFilterFocus && this.filter && focus(this.$refs.filterInput.$el);
this.focusedOptionIndex = this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : this.editable ? -1 : this.findSelectedOptionIndex();
this.autoUpdateModel();
}, 1);
},
onOverlayAfterEnter() {
@ -900,8 +900,11 @@ export default {
});
},
autoUpdateModel() {
if (this.selectOnFocus && this.autoOptionFocus && !this.$filled) {
if (this.autoOptionFocus) {
this.focusedOptionIndex = this.findFirstFocusedOptionIndex();
}
if (this.selectOnFocus && this.autoOptionFocus && !this.$filled) {
this.onOptionSelect(null, this.visibleOptions[this.focusedOptionIndex], false);
}
},