From 059cbfff558ea45506fac62b2a369b1a3dd6ccf7 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 31 Jul 2023 10:10:16 -0600 Subject: [PATCH] SearchMixin: Limit number of JSON search results --- api/js/etemplate/Et2Select/SearchMixin.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/js/etemplate/Et2Select/SearchMixin.ts b/api/js/etemplate/Et2Select/SearchMixin.ts index a4a12d2a06..2afb0578e3 100644 --- a/api/js/etemplate/Et2Select/SearchMixin.ts +++ b/api/js/etemplate/Et2Select/SearchMixin.ts @@ -1196,8 +1196,14 @@ export const Et2WithSearchMixin = >(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) =>