Skip to content

Commit

Permalink
Does not trigger redirectUrl logic
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraBeatris committed Feb 20, 2025
1 parent 07f897c commit 566fd8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .changeset/old-cherries-laugh.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
'@clerk/types': patch
---

Display after-auth tasks on `SignIn` and `SignUp` components
Navigate to after-auth tasks
16 changes: 8 additions & 8 deletions packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,12 @@ export class Clerk implements ClerkInterface {

let newSession = session === undefined ? this.session : session;

// todo - handle the transition on token poller
const hasNewTask = newSession && !!newSession?.tasks;
if (hasNewTask && newSession) {
eventBus.dispatch(events.NewSessionTask, newSession);
}

// At this point, the `session` variable should contain either an `SignedInSessionResource`
// ,`null` or `undefined`.
// We now want to set the last active organization id on that session (if it exists).
Expand Down Expand Up @@ -932,11 +938,6 @@ export class Clerk implements ClerkInterface {
eventBus.dispatch(events.TokenUpdate, { token: null });
}

const hasNewTask = newSession && !!newSession?.tasks;
if (hasNewTask && newSession) {
eventBus.dispatch(events.NewSessionTask, newSession);
}

//2. If there's a beforeEmit, typically we're navigating. Emit the session as
// undefined, then wait for beforeEmit to complete before emitting the new session.
// When undefined, neither SignedIn nor SignedOut renders, which avoids flickers or
Expand All @@ -953,8 +954,7 @@ export class Clerk implements ClerkInterface {
beforeUnloadTracker?.stopTracking();
}

// todo -> how to handle navigation to after sign-in?
if (redirectUrl && !beforeEmit) {
if (redirectUrl && !beforeEmit && !hasNewTask) {
beforeUnloadTracker?.startTracking();
this.#setTransitiveState();

Expand Down Expand Up @@ -1045,7 +1045,6 @@ export class Clerk implements ClerkInterface {
...(options?.metadata ? { __internal_metadata: options?.metadata } : {}),
windowNavigate,
};
console.log(stripOrigin(toURL));
// React router only wants the path, search or hash portion.
return await customNavigate(stripOrigin(toURL), metadata);
};
Expand Down Expand Up @@ -1123,6 +1122,7 @@ export class Clerk implements ClerkInterface {
return buildURL({ base: waitlistUrl, hashSearchParams: [initValues] }, { stringify: true });
}

// todo(fix sign up navigation)
public buildTasksUrl({ task, origin }: { task?: SessionTask; origin?: 'SignIn' | 'SignUp' }): string {
if (!task) {
return '';
Expand Down

0 comments on commit 566fd8c

Please sign in to comment.