Skip to content

Commit 4c1c480

Browse files
anyujkendelljoseph
authored andcommitted
fix(plugin-multi-tenant): make tenant selector respect order if orderable enabled for tenant collection (#12314)
### What? Tenant Selector doesn’t honor the custom order when ‘orderable’ is enabled for Tenant collection ### Why? Currently, it uses "useAsTitle" to sort. In some use cases, for example, when a user manages multiple tenants that have an inherent priority (such as usage frequency), sorting purely by the useAsTitle isn’t very practical. ### How? Get "orderable" config from the tenant collection's config, if it has "orderable" set as true, it will use _order to sort. If not, it will use "useAsTitle" to sort as default. Fixes #12246 ![image](https://github.com/user-attachments/assets/b5c4ad5e-3503-4789-91f6-a7aafb326e32)
1 parent 633960d commit 4c1c480

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/plugin-multi-tenant/src/queries/findTenantOptions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ export const findTenantOptions = async ({
1414
useAsTitle,
1515
user,
1616
}: Args): Promise<PaginatedDocs> => {
17+
const isOrderable = payload.collections[tenantsCollectionSlug]?.config?.orderable || false
1718
return payload.find({
1819
collection: tenantsCollectionSlug,
1920
depth: 0,
2021
limit,
2122
overrideAccess: false,
2223
select: {
2324
[useAsTitle]: true,
25+
...(isOrderable ? { _order: true } : {}),
2426
},
25-
sort: useAsTitle,
27+
sort: isOrderable ? '_order' : useAsTitle,
2628
user,
2729
})
2830
}

0 commit comments

Comments
 (0)