Skip to content

Commit d6269e6

Browse files
committed
Add changeset
1 parent c96f964 commit d6269e6

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed

.changeset/common-mice-ring.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Prevent organization list from displaying after creating an organization through the force organization selection flow

packages/clerk-js/src/ui/components/OrganizationList/OrganizationListPage.tsx

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,7 @@ export const OrganizationListPage = withCardStateProvider(() => {
9191

9292
return (
9393
<FlowCard>
94-
{isLoading && (
95-
<Flex
96-
direction={'row'}
97-
align={'center'}
98-
justify={'center'}
99-
sx={t => ({
100-
height: '100%',
101-
minHeight: t.sizes.$60,
102-
})}
103-
>
104-
<Spinner
105-
size={'lg'}
106-
colorScheme={'primary'}
107-
elementDescriptor={descriptors.spinner}
108-
/>
109-
</Flex>
110-
)}
111-
94+
{isLoading && <FlowLoadingState />}
11295
{!isLoading && <OrganizationListFlows showListInitially={!(hidePersonal && !hasAnyData)} />}
11396
</FlowCard>
11497
);
@@ -233,29 +216,16 @@ const ForceOrganizationSelectionFlow = () => {
233216
const { navigateAfterCreateOrganization, hideSlug } = useOrganizationListContext();
234217
const { userMemberships, userSuggestions, userInvitations } = useOrganizationListInView();
235218

236-
const [isNavigating, setIsNavigating] = useState(false);
237-
const isLoading = isNavigating || !!(userMemberships?.count || userInvitations?.count || userSuggestions?.count);
219+
const [isNavigatingAfterOrgCreation, setIsNavigatingAfterOrgCreation] = useState(false);
220+
const isLoading =
221+
isNavigatingAfterOrgCreation || !!(userMemberships?.count || userInvitations?.count || userSuggestions?.count);
238222

239223
const [isCreateOrganizationFlow, setIsCreateOrganizationFlow] = useState(!userMemberships?.data?.length);
240224

241225
if (isLoading) {
242226
return (
243227
<FlowCard>
244-
<Flex
245-
direction={'row'}
246-
align={'center'}
247-
justify={'center'}
248-
sx={t => ({
249-
height: '100%',
250-
minHeight: t.sizes.$60,
251-
})}
252-
>
253-
<Spinner
254-
size={'lg'}
255-
colorScheme={'primary'}
256-
elementDescriptor={descriptors.spinner}
257-
/>
258-
</Flex>
228+
<FlowLoadingState />
259229
</FlowCard>
260230
);
261231
}
@@ -274,7 +244,9 @@ const ForceOrganizationSelectionFlow = () => {
274244
startPage={{ headerTitle: localizationKeys('organizationList.createOrganization') }}
275245
skipInvitationScreen
276246
navigateAfterCreateOrganization={org => {
277-
setIsNavigating(true);
247+
// During a force organization selection flow, keep displaying the creation form in a loading state.
248+
// This allows the client-side navigation to complete before transitioning away from this view.
249+
setIsNavigatingAfterOrgCreation(true);
278250
return navigateAfterCreateOrganization(org);
279251
}}
280252
hideSlug={hideSlug}
@@ -300,3 +272,21 @@ const FlowCard = ({ children }: PropsWithChildren) => {
300272
</Card.Root>
301273
);
302274
};
275+
276+
const FlowLoadingState = () => (
277+
<Flex
278+
direction={'row'}
279+
align={'center'}
280+
justify={'center'}
281+
sx={t => ({
282+
height: '100%',
283+
minHeight: t.sizes.$60,
284+
})}
285+
>
286+
<Spinner
287+
size={'lg'}
288+
colorScheme={'primary'}
289+
elementDescriptor={descriptors.spinner}
290+
/>
291+
</Flex>
292+
);

0 commit comments

Comments
 (0)