-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(clerk-js): Use afterSwitchSessionUrl
switching sessions within UserButton
#4726
fix(clerk-js): Use afterSwitchSessionUrl
switching sessions within UserButton
#4726
Conversation
🦋 Changeset detectedLatest commit: 3e3e53d The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -907,7 +907,7 @@ export class Clerk implements ClerkInterface { | |||
beforeUnloadTracker?.stopTracking(); | |||
} | |||
|
|||
if (redirectUrl) { | |||
if (redirectUrl && !beforeEmit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clerk.signOut()
uses both beforeEmit
and redirectUrl
which is an incorrect state as the redirection should be trigger by only one of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we fix signOut? Then throw in this if both beforeEmit and redirectUrl come through.
…g-afterswitchsessionurl-on-switching
packages/clerk-js/src/ui/components/UserButton/useMultisessionActions.tsx
Show resolved
Hide resolved
packages/clerk-js/src/ui/components/UserButton/useMultisessionActions.tsx
Outdated
Show resolved
Hide resolved
packages/clerk-js/src/ui/components/UserButton/useMultisessionActions.tsx
Outdated
Show resolved
Hide resolved
…g-afterswitchsessionurl-on-switching
…chsessionurl-on-switching
!snapshot |
Hey @panteliselef - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested the snapshot focused on the afterSwitchSessionUrl
and it works like a charm! Verified the bug was there before, upgraded and it went away. Found no way to break it. Not quite qualified to review the other changes.
This change will mean that if you relied on afterSignInUrl
working before, things will break right (in my testing it did)? I think that's fine and expected considering it's undocumented and does not exist on the types.
…g-afterswitchsessionurl-on-switching
redirectUrl: '/after-sign-out', | ||
}); | ||
expect(sut.navigate).toHaveBeenCalledWith('/after-sign-out'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was only passing because we were always doing this, inside signOut
const defaultCb = () => this.navigate(redirectUrl);
Description
When switching session within
<UserButton/>
, we should respect the value ofafterSwitchSessionUrl
. Only inside the SignInAccountSwitcher internal component we need to useafterSignInUrl
.Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change