darrenjennings / vue-autosuggest

🔍 Vue autosuggest component.
https://darrenjennings.github.io/vue-autosuggest
MIT License
621 stars 91 forks source link

Can't access property "liClass", i is undefined #237

Closed axlu closed 1 year ago

axlu commented 1 year ago

vue: 2 node: 18.12.1 vue-autosuggest: 2.2.0

Hello, we have multiple vue-autosuggests on our site that works without any issues. I'm trying to add a new one and keep getting this error, whenever I start typing in the new input. "TypeError: can't access property "liClass", i is undefined".

"normalizeItem" is listed last in the error stack.

In Autosuggest.vue I can see a call to normalizeItem with this.computedSection[i].name and ...[i],type. So I guess that means that there is something wrong with the computedSections. Vue devtools shows me that I have an array of two objects. But I guess things happens along the way that I'm not seeing.

The only difference between the new component and the old ones is that I am now using sectionConfigs. They look like this.

sectionConfigs: { page: { sectionName: 'sida', type: 'page-section', limit: 4, }, profile: { sectionName: 'profil', type: 'profil-section', limit: 4, }, },

suggestions prop looks like this before data is added.

suggestions: [ { name: 'sida', type: 'page-section', liClass: 'test-li-igen', data: [], }, { name: 'profil', type: 'profil-section', liClass: 'test-li-igen', data: [], }, ],

template looks like this.

image

And input props like this. Don't know if it matters or not but I'll throw it in here. inputProps: { id: 'bookmark-search-new-id', placeholder: this.$t('placeholder'), autocomplete: 'off', 'aria-label': this.$t('placeholder'), class: 'test-class', },