SearchMixin: Limit number of JSON search results

This commit is contained in:
nathan 2023-07-31 10:10:16 -06:00
parent 149e2fec76
commit 059cbfff55

View File

@ -1196,8 +1196,14 @@ export const Et2WithSearchMixin = <T extends Constructor<LitElement>>(superclass
{ {
return option.label.toLowerCase().includes(lower_search) || option.value.includes(search) 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 // Add the matches
this.processRemoteResults(filtered); this.processRemoteResults(filtered, totalCount);
return filtered; return filtered;
}) })
.catch((_err) => .catch((_err) =>