Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sour-meals-see.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Improve multi-session navigation to tasks
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Header } from '@/ui/elements/Header';
import { PreviewButton } from '@/ui/elements/PreviewButton';
import { UserPreview } from '@/ui/elements/UserPreview';

import { withRedirectToAfterSignIn, withRedirectToSignInTask } from '../../common';
import { withRedirectToAfterSignIn } from '../../common';
import { useEnvironment, useSignInContext, useSignOutContext } from '../../contexts';
import { Col, descriptors, Flow, localizationKeys } from '../../customizables';
import { Add, SwitchArrowRight } from '../../icons';
Expand All @@ -15,10 +15,11 @@ import { useMultisessionActions } from '../UserButton/useMultisessionActions';
const SignInAccountSwitcherInternal = () => {
const card = useCardState();
const { userProfileUrl } = useEnvironment().displayConfig;
const { afterSignInUrl, path: signInPath, signInUrl } = useSignInContext();
const { afterSignInUrl, path: signInPath, signInUrl, taskUrl } = useSignInContext();
const { navigateAfterSignOut } = useSignOutContext();
const { handleSignOutAllClicked, handleSessionClicked, signedInSessions, handleAddAccountClicked } =
useMultisessionActions({
taskUrl,
navigateAfterSignOut,
afterSwitchSessionUrl: afterSignInUrl,
userProfileUrl,
Expand Down Expand Up @@ -125,6 +126,4 @@ const SignInAccountSwitcherInternal = () => {
</Flow.Part>
);
};
export const SignInAccountSwitcher = withRedirectToSignInTask(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the withRedirectToSignInTask guard from here since the user should be allowed to switch sessions regardless if they have a pending task

withRedirectToAfterSignIn(withCardStateProvider(SignInAccountSwitcherInternal)),
);
export const SignInAccountSwitcher = withRedirectToAfterSignIn(withCardStateProvider(SignInAccountSwitcherInternal));
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type UseMultisessionActionsParams = {
afterSwitchSessionUrl?: string;
userProfileUrl?: string;
signInUrl?: string;
taskUrl?: string | null;
} & Pick<UserButtonProps, 'userProfileMode' | 'appearance' | 'userProfileProps'>;

export const useMultisessionActions = (opts: UseMultisessionActionsParams) => {
Expand Down Expand Up @@ -81,6 +82,11 @@ export const useMultisessionActions = (opts: UseMultisessionActionsParams) => {
return;
}

if (opts.taskUrl) {
await navigate(opts.taskUrl);
return;
}

await navigateIfTaskExists(session, {
baseUrl: opts.signInUrl ?? displayConfig.signInUrl,
navigate,
Expand Down
Loading