From 15e909ae996639120288a0c2b2605279fbf047c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20J=C3=B6nsson?= Date: Sun, 10 Sep 2023 14:27:45 +0200 Subject: [PATCH] Retain order of organizations in OrgSwitcher during filtering --- .../components/OrganizationSwitcher/useOrgSwitcher.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/features/organizations/components/OrganizationSwitcher/useOrgSwitcher.ts b/src/features/organizations/components/OrganizationSwitcher/useOrgSwitcher.ts index 39d2b20227..5468c9ddf7 100644 --- a/src/features/organizations/components/OrganizationSwitcher/useOrgSwitcher.ts +++ b/src/features/organizations/components/OrganizationSwitcher/useOrgSwitcher.ts @@ -50,6 +50,7 @@ function useOrgSwitcher(orgId: number, searchString: string) { const recentOrgsFuse = useMemo(() => { return new Fuse(recentOrgs, { keys: ['title'], + shouldSort: false, threshold: 0.4, }); }, [recentOrgs]); @@ -61,7 +62,11 @@ function useOrgSwitcher(orgId: number, searchString: string) { }, [searchString]); const allOrgsFuse = useMemo(() => { - return new Fuse(flatOrgData, { keys: ['title'], threshold: 0.4 }); + return new Fuse(flatOrgData, { + keys: ['title'], + shouldSort: false, + threshold: 0.4, + }); }, [flatOrgData]); const filteredAllOrgs = useMemo(() => {