Closed atomcat1978 closed 2 years ago
I bet, the list should be re-filtered. Something like what resetListToAllItemsAndOpen
does.
Seems like a call to search
does the trick:
function prepareListItems() {
let timerId
if (debug) {
timerId = `Autocomplete prepare list ${inputId ? `(id: ${inputId})` : ""}`
console.time(timerId)
console.log("Prepare items to search")
console.log("items: " + JSON.stringify(items))
}
if (!Array.isArray(items)) {
console.warn("Autocomplete items / search function did not return array but", items)
items = []
}
const length = items ? items.length : 0
listItems = new Array(length)
if (length > 0) {
items.forEach((item, i) => {
const listItem = getListItem(item)
if (listItem === undefined) {
console.log("Undefined item for: ", item)
}
listItems[i] = listItem
})
search() // << -- Here
}
if (debug) {
console.log(listItems.length + " items to search")
console.timeEnd(timerId)
}
}
Thanks for reporting, I will have a look.
Just a comment: the suggested solution above does not handle if items are set to an empty/null list. So, possibly we should do a search call in all cases.
if (length > 0) {
items.forEach((item, i) => {
const listItem = getListItem(item)
if (listItem === undefined) {
console.log("Undefined item for: ", item)
}
listItems[i] = listItem
})
}
search() // << -- Here
Also maybe search code could have a short circuit if the provided items are empty/null.
Should be fixed in 2.3.5.
Updating items invoked prepareListItems (
$: items, prepareListItems()
), however the list offilteredListItems
stays the same. This leads to inconsistent data view if the dropdown is opened again using the down arrow.