From 80f0e1129970fdadfd18da1884f70ec50b5dc787 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 6 Dec 2024 12:15:39 -0500 Subject: [PATCH] Added sort to Org Names in FilterTags - Added a map and sort function the org names accessor function. - Added sortedValues as an arg to the ellipsis function. --- frontend/src/pages/Search/FilterTags.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/Search/FilterTags.tsx b/frontend/src/pages/Search/FilterTags.tsx index ee326156..a7a800b8 100644 --- a/frontend/src/pages/Search/FilterTags.tsx +++ b/frontend/src/pages/Search/FilterTags.tsx @@ -94,10 +94,18 @@ const FIELD_TO_LABEL_MAP: FieldToLabelMap = { return 'Organization'; }, filterValueAccssor: (t) => { + if (Array.isArray(t)) { + return t + .map((org) => org.name) + .sort((a: string, b: string) => { + return a.localeCompare(b); + }); + } return t.name; }, - trimAfter: 2 + trimAfter: 3 }, + query: { labelAccessor: (t) => { return 'Query'; @@ -165,9 +173,7 @@ export const FilterTags: React.FC = ({ filters, removeFilter }) => { : nextFilter.values; const value = fieldAccessors ? ellipsisPastIndex( - nextFilter.values.map((item: any) => - fieldAccessors.filterValueAccssor(item) - ), + sortedValues, fieldAccessors.trimAfter ? fieldAccessors.trimAfter - 1 : null ).join(', ') : sortedValues.join(', ');