Skip to content

Commit

Permalink
Prevent undefined exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Massi-X authored Dec 7, 2024
1 parent 8d619fa commit f1b5285
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/parts/suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -503,4 +504,4 @@ export default {
return this.settings.templates.dropdownItem.apply(this, [{...suggestion, mappedValue}, this])
}).join("")
}
}
}

0 comments on commit f1b5285

Please sign in to comment.