From f1b5285edfd4d6e8e647537b0eea542093218cac Mon Sep 17 00:00:00 2001 From: Massi-X <7504132+Massi-X@users.noreply.github.com> Date: Sat, 7 Dec 2024 14:37:13 +0100 Subject: [PATCH] Prevent undefined exceptions --- src/parts/suggestions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/parts/suggestions.js b/src/parts/suggestions.js index bc8a6971..b7c59795 100644 --- a/src/parts/suggestions.js +++ b/src/parts/suggestions.js @@ -294,6 +294,7 @@ export default { isNoMatch = value == 'noMatch', isMixMode = _s.mode == 'mix', tagData = this.suggestedListItems.find(item => (item.value ?? item) == value) + tagTextElem = this.DOM.scope.querySelector('.' + _s.classNames.tagText) // The below event must be triggered, regardless of anything else which might go wrong this.trigger('dropdown:select', {data:tagData, elm, event}) @@ -325,7 +326,7 @@ export default { // select mode: reset the dropdown to show all options again to the user if(_s.mode == 'select' && !this.state.composing && this.userInput) - setTimeout(() => this.DOM.scope.querySelector('.' + _s.classNames.tagText).focus(), 0) //set the focus back to input on each select to ensure consistent behavior + setTimeout(() => tagTextElem && tagTextElem.focus(), 0) //set the focus back to input on each select to ensure consistent behavior closeOnSelect && setTimeout(this.dropdown.hide.bind(this)) @@ -503,4 +504,4 @@ export default { return this.settings.templates.dropdownItem.apply(this, [{...suggestion, mappedValue}, this]) }).join("") } -} \ No newline at end of file +}