Skip to content

Commit 05a1039

Browse files
committed
Prevent undefined exceptions
1 parent 8d619fa commit 05a1039

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/parts/suggestions.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ export default {
293293
var value = elm.getAttribute('value'),
294294
isNoMatch = value == 'noMatch',
295295
isMixMode = _s.mode == 'mix',
296-
tagData = this.suggestedListItems.find(item => (item.value ?? item) == value)
296+
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)