Skip to content

Commit bc7bb65

Browse files
committed
Do not display organization list for force-an-org without memberships
1 parent 6f474d2 commit bc7bb65

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useOrganizationList, useUser } from '@clerk/shared/react';
1+
import { useOrganizationList, useSessionContext, useUser } from '@clerk/shared/react';
22
import { useContext, useState } from 'react';
33

44
import { Action, Actions } from '@/ui/elements/Actions';
@@ -117,6 +117,8 @@ const OrganizationListFlows = ({ showListInitially }: { showListInitially: boole
117117
const { navigateAfterCreateOrganization, skipInvitationScreen, hideSlug } = useOrganizationListContext();
118118
const [isCreateOrganizationFlow, setCreateOrganizationFlow] = useState(!showListInitially);
119119
const sessionTasksContext = useContext(SessionTasksContext);
120+
const session = useSessionContext();
121+
120122
return (
121123
<>
122124
{!isCreateOrganizationFlow && (
@@ -135,7 +137,18 @@ const OrganizationListFlows = ({ showListInitially }: { showListInitially: boole
135137
startPage={{ headerTitle: localizationKeys('organizationList.createOrganization') }}
136138
skipInvitationScreen={skipInvitationScreen}
137139
navigateAfterCreateOrganization={org =>
138-
navigateAfterCreateOrganization(org).then(() => setCreateOrganizationFlow(false))
140+
navigateAfterCreateOrganization(org).then(() => {
141+
const isForceOrganizationSelectionFlow = sessionTasksContext && session?.currentTask.key === 'org';
142+
143+
// During a force organization selection flow, keep displaying the creation form in a loading state
144+
// rather than showing the organization list. This allows the client-side navigation to complete
145+
// before transitioning away from this view.
146+
if (isForceOrganizationSelectionFlow) {
147+
return;
148+
}
149+
150+
setCreateOrganizationFlow(false);
151+
})
139152
}
140153
onCancel={
141154
showListInitially && isCreateOrganizationFlow ? () => setCreateOrganizationFlow(false) : undefined

0 commit comments

Comments
 (0)