Fixed #4881 - Listbox: select-on-focus causes a crash

pull/4899/head
tugcekucukoglu 2023-11-27 17:56:27 +03:00
parent 75fb031fb4
commit 098c7a5128
1 changed files with 3 additions and 2 deletions

View File

@ -228,6 +228,7 @@ export default {
onListFocus(event) {
this.focused = true;
this.focusedOptionIndex = this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : -1;
this.autoUpdateModel();
this.$emit('focus', event);
},
onListBlur(event) {
@ -327,7 +328,7 @@ export default {
let metaSelection = this.optionTouched ? false : this.metaKeySelection;
if (metaSelection) {
let metaKey = event.metaKey || event.ctrlKey;
let metaKey = event && (event.metaKey || event.ctrlKey);
if (selected) {
if (metaKey) {
@ -632,7 +633,7 @@ export default {
}
},
autoUpdateModel() {
if (this.selectOnFocus && this.autoOptionFocus && !this.hasSelectedOption && !this.multiple) {
if (this.selectOnFocus && this.autoOptionFocus && !this.hasSelectedOption && !this.multiple && this.focused) {
this.focusedOptionIndex = this.findFirstFocusedOptionIndex();
this.onOptionSelect(null, this.visibleOptions[this.focusedOptionIndex]);
}