Skip to content

Commit 2a90b68

Browse files
authored
fix(clerk-js): Do not trigger after-auth navigation from useMultisessionActions (#6323)
1 parent 31df07b commit 2a90b68

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

.changeset/deep-poems-sneeze.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/clerk-react': patch
4+
'@clerk/types': minor
5+
---
6+
7+
Do not trigger after-auth navigation from `useMultisessionActions`

packages/clerk-js/src/core/clerk.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type {
1919
__experimental_CheckoutOptions,
2020
__internal_CheckoutProps,
2121
__internal_ComponentNavigationContext,
22+
__internal_NavigateToTaskIfAvailableParams,
2223
__internal_OAuthConsentProps,
2324
__internal_PlanDetailsProps,
2425
__internal_SubscriptionDetailsProps,
@@ -50,7 +51,6 @@ import type {
5051
JoinWaitlistParams,
5152
ListenerCallback,
5253
NavigateOptions,
53-
NextTaskParams,
5454
OrganizationListProps,
5555
OrganizationProfileProps,
5656
OrganizationResource,
@@ -1332,7 +1332,9 @@ export class Clerk implements ClerkInterface {
13321332
this.#emit();
13331333
};
13341334

1335-
public __internal_navigateToTaskIfAvailable = async ({ redirectUrlComplete }: NextTaskParams = {}): Promise<void> => {
1335+
public __internal_navigateToTaskIfAvailable = async ({
1336+
redirectUrlComplete,
1337+
}: __internal_NavigateToTaskIfAvailableParams = {}): Promise<void> => {
13361338
const session = this.session;
13371339
if (!session || !this.environment) {
13381340
return;
@@ -1348,15 +1350,16 @@ export class Clerk implements ClerkInterface {
13481350
return;
13491351
}
13501352

1351-
const tracker = createBeforeUnloadTracker(this.#options.standardBrowser);
1352-
const defaultRedirectUrlComplete = this.client?.signUp ? this.buildAfterSignUpUrl() : this.buildAfterSignInUrl();
1353+
if (redirectUrlComplete) {
1354+
const tracker = createBeforeUnloadTracker(this.#options.standardBrowser);
13531355

1354-
await tracker.track(async () => {
1355-
await this.navigate(redirectUrlComplete ?? defaultRedirectUrlComplete);
1356-
});
1356+
await tracker.track(async () => {
1357+
await this.navigate(redirectUrlComplete);
1358+
});
13571359

1358-
if (tracker.isUnloading()) {
1359-
return;
1360+
if (tracker.isUnloading()) {
1361+
return;
1362+
}
13601363
}
13611364
};
13621365

packages/react/src/isomorphicClerk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { loadClerkJsScript } from '@clerk/shared/loadClerkJsScript';
44
import { handleValueOrFn } from '@clerk/shared/utils';
55
import type {
66
__internal_CheckoutProps,
7+
__internal_NavigateToTaskIfAvailableParams,
78
__internal_OAuthConsentProps,
89
__internal_PlanDetailsProps,
910
__internal_SubscriptionDetailsProps,
@@ -30,7 +31,6 @@ import type {
3031
JoinWaitlistParams,
3132
ListenerCallback,
3233
LoadedClerk,
33-
NextTaskParams,
3434
OrganizationListProps,
3535
OrganizationProfileProps,
3636
OrganizationResource,
@@ -731,7 +731,7 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
731731
}
732732
};
733733

734-
__internal_navigateToTaskIfAvailable = async (params?: NextTaskParams): Promise<void> => {
734+
__internal_navigateToTaskIfAvailable = async (params?: __internal_NavigateToTaskIfAvailableParams): Promise<void> => {
735735
if (this.clerkjs) {
736736
return this.clerkjs.__internal_navigateToTaskIfAvailable(params);
737737
} else {

packages/types/src/clerk.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -815,12 +815,10 @@ export interface Clerk {
815815
joinWaitlist: (params: JoinWaitlistParams) => Promise<WaitlistResource>;
816816

817817
/**
818-
* Navigates to the next task or redirects to completion URL.
819-
* If the current session has pending tasks, it navigates to the next task.
820-
* If all tasks are complete, it navigates to the provided completion URL or defaults to the origin redirect URL (either from sign-in or sign-up).
818+
* Navigates to the current task or redirects to `redirectUrlComplete` once the session is `active`.
821819
* @internal
822820
*/
823-
__internal_navigateToTaskIfAvailable: (params?: NextTaskParams) => Promise<void>;
821+
__internal_navigateToTaskIfAvailable: (params?: __internal_NavigateToTaskIfAvailableParams) => Promise<void>;
824822

825823
/**
826824
* This is an optional function.
@@ -2005,7 +2003,7 @@ export interface AuthenticateWithGoogleOneTapParams {
20052003
legalAccepted?: boolean;
20062004
}
20072005

2008-
export interface NextTaskParams {
2006+
export interface __internal_NavigateToTaskIfAvailableParams {
20092007
/**
20102008
* Full URL or path to navigate to after successfully resolving all tasks
20112009
* @default undefined

0 commit comments

Comments
 (0)