Skip to content

Commit

Permalink
fix(clerk-js): Fix the conditional render condition for organizationP…
Browse files Browse the repository at this point in the history
…reviewSecondaryIdentifier (#2936)
  • Loading branch information
desiprisg authored Mar 6, 2024
1 parent ceb74c4 commit 097ec48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-crabs-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

The organizationPreviewSecondaryIdentifier element will no longer be rendered empty inside the organization switcher's list.
6 changes: 4 additions & 2 deletions packages/clerk-js/src/ui/elements/OrganizationPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const OrganizationPreview = (props: OrganizationPreviewProps) => {

const membership = user?.organizationMemberships.find(membership => membership.organization.id === organization.id);
const unlocalizedRoleLabel = options?.find(a => a.value === membership?.role)?.label;
const roleLabel = localizeCustomRole(membership?.role) || unlocalizedRoleLabel;

const mainTextSize =
mainIdentifierVariant || ({ xs: 'subtitle', sm: 'caption', md: 'subtitle', lg: 'h1' } as const)[size];
Expand Down Expand Up @@ -91,12 +92,13 @@ export const OrganizationPreview = (props: OrganizationPreviewProps) => {
>
{organization.name} {badge}
</Text>
{organization.name && (

{roleLabel && (
<Text
elementDescriptor={descriptors.organizationPreviewSecondaryIdentifier}
elementId={descriptors.organizationPreviewSecondaryIdentifier.setId(elementId)}
localizationKey={localizeCustomRole(membership?.role) || unlocalizedRoleLabel}
as='span'
localizationKey={roleLabel}
truncate
/>
)}
Expand Down

0 comments on commit 097ec48

Please sign in to comment.