Skip to content

Commit

Permalink
fixes #1348 - when whitelist consists of promitives the `getSuggestio…
Browse files Browse the repository at this point in the history
…nDataByNode` method failed because it expected an a liste consisting of Objects with a `value` property
  • Loading branch information
yairEO committed Jun 12, 2024
1 parent 0399c04 commit 65c75ea
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/parts/suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default {
let shouldAutocompleteOnKey = !_s.autoComplete.rightKey || !_s.autoComplete.tabKey

// in mix-mode, treat arrowRight like Enter key, so a tag will be created
if( !isMixMode && !isSelectMode && selectedElm && shouldAutocompleteOnKey && !this.state.editing ){
if( !isMixMode && !isSelectMode && selectedElm && shouldAutocompleteOnKey && !this.state.editing && selectedElmData ){
e.preventDefault() // prevents blur so the autocomplete suggestion will not become a tag
var value = this.dropdown.getMappedValue(selectedElmData)

Expand Down Expand Up @@ -196,8 +196,14 @@ export default {
* @returns Object
*/
getSuggestionDataByNode( tagElm ){
var value = tagElm && tagElm.getAttribute('value')
return this.suggestedListItems.find(item => item.value == value) || null
var item, value = tagElm && tagElm.getAttribute('value')

for(var i = this.suggestedListItems.length; i--; ) {
item = this.suggestedListItems[i]
if( isObject(item) && item.value == value ) return item
// for primitive whitelist items:
else if( item == value ) return {value: item}
}
},

getNextOrPrevOption(selected, next = true) {
Expand Down

0 comments on commit 65c75ea

Please sign in to comment.