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 ↗︎
|
| } | ||
|
|
||
| if (redirectUrl) { | ||
| if (redirectUrl && !beforeEmit) { |
There was a problem hiding this comment.
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.
Should we fix signOut? Then throw in this if both beforeEmit and redirectUrl come through.
…g-afterswitchsessionurl-on-switching
…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/astro@2.0.1-snapshot.v20241209201459 --save-exact
npm i @clerk/backend@1.20.3-snapshot.v20241209201459 --save-exact
npm i @clerk/chrome-extension@2.0.9-snapshot.v20241209201459 --save-exact
npm i @clerk/clerk-js@5.40.3-snapshot.v20241209201459 --save-exact
npm i @clerk/elements@0.21.4-snapshot.v20241209201459 --save-exact
npm i @clerk/clerk-expo@2.4.5-snapshot.v20241209201459 --save-exact
npm i @clerk/expo-passkeys@0.0.17-snapshot.v20241209201459 --save-exact
npm i @clerk/express@1.3.26-snapshot.v20241209201459 --save-exact
npm i @clerk/fastify@2.0.28-snapshot.v20241209201459 --save-exact
npm i @clerk/localizations@3.8.2-snapshot.v20241209201459 --save-exact
npm i @clerk/nextjs@6.8.3-snapshot.v20241209201459 --save-exact
npm i @clerk/nuxt@0.0.13-snapshot.v20241209201459 --save-exact
npm i @clerk/clerk-react@5.19.3-snapshot.v20241209201459 --save-exact
npm i @clerk/react-router@0.0.2-snapshot.v20241209201459 --save-exact
npm i @clerk/remix@4.3.6-snapshot.v20241209201459 --save-exact
npm i @clerk/clerk-sdk-node@5.0.77-snapshot.v20241209201459 --save-exact
npm i @clerk/shared@2.19.4-snapshot.v20241209201459 --save-exact
npm i @clerk/tanstack-start@0.6.6-snapshot.v20241209201459 --save-exact
npm i @clerk/testing@1.3.38-snapshot.v20241209201459 --save-exact
npm i @clerk/themes@2.1.55-snapshot.v20241209201459 --save-exact
npm i @clerk/types@4.39.2-snapshot.v20241209201459 --save-exact
npm i @clerk/ui@0.2.4-snapshot.v20241209201459 --save-exact
npm i @clerk/vue@0.0.17-snapshot.v20241209201459 --save-exact |
Ephem
left a comment
There was a problem hiding this comment.
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
| beforeEmit: expect.any(Function), | ||
| redirectUrl: '/after-sign-out', | ||
| }); | ||
| expect(sut.navigate).toHaveBeenCalledWith('/after-sign-out'); |
There was a problem hiding this comment.
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 testruns as expected.pnpm buildruns as expected.Type of change