SearchMixin: Limit number of JSON search results

This commit is contained in:
nathan 2023-07-31 10:10:16 -06:00
parent 027ad398d6
commit 6b183db6e0

View File

@ -1201,8 +1201,14 @@ export const Et2WithSearchMixin = <T extends Constructor<LitElement>>(superclass
{
return option.label.toLowerCase().includes(lower_search) || option.value.includes(search)
});
// Limit results
const totalCount = filtered.length;
if(filtered.length > Et2WidgetWithSearch.RESULT_LIMIT)
{
filtered.splice(Et2WidgetWithSearch.RESULT_LIMIT);
}
// Add the matches
this.processRemoteResults(filtered);
this.processRemoteResults(filtered, totalCount);
return filtered;
})
.catch((_err) =>