Skip to content

Commit f1b5285

Browse files
authored
Prevent undefined exceptions
1 parent 8d619fa commit f1b5285

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/parts/suggestions.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ export default {
294294
isNoMatch = value == 'noMatch',
295295
isMixMode = _s.mode == 'mix',
296296
tagData = this.suggestedListItems.find(item => (item.value ?? item) == value)
297+
tagTextElem = this.DOM.scope.querySelector('.' + _s.classNames.tagText)
297298

298299
// The below event must be triggered, regardless of anything else which might go wrong
299300
this.trigger('dropdown:select', {data:tagData, elm, event})
@@ -325,7 +326,7 @@ export default {
325326

326327
// select mode: reset the dropdown to show all options again to the user
327328
if(_s.mode == 'select' && !this.state.composing && this.userInput)
328-
setTimeout(() => this.DOM.scope.querySelector('.' + _s.classNames.tagText).focus(), 0) //set the focus back to input on each select to ensure consistent behavior
329+
setTimeout(() => tagTextElem && tagTextElem.focus(), 0) //set the focus back to input on each select to ensure consistent behavior
329330

330331
closeOnSelect && setTimeout(this.dropdown.hide.bind(this))
331332

@@ -503,4 +504,4 @@ export default {
503504
return this.settings.templates.dropdownItem.apply(this, [{...suggestion, mappedValue}, this])
504505
}).join("")
505506
}
506-
}
507+
}

0 commit comments

Comments
 (0)