From 098c7a5128c534bea627e3c355e966b4588e1dbb Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Mon, 27 Nov 2023 17:56:27 +0300 Subject: [PATCH] Fixed #4881 - Listbox: select-on-focus causes a crash --- components/lib/listbox/Listbox.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/lib/listbox/Listbox.vue b/components/lib/listbox/Listbox.vue index 4155b716b..6cbc89035 100755 --- a/components/lib/listbox/Listbox.vue +++ b/components/lib/listbox/Listbox.vue @@ -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]); }