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/eager-cats-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Guard against navigation to root sign-in route during `setActive` in `SignInFactorOne`
14 changes: 11 additions & 3 deletions packages/clerk-js/src/ui/components/SignIn/SignInFactorOne.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useClerk } from '@clerk/shared/react';
import type { SignInFactor } from '@clerk/types';
import React from 'react';

Expand Down Expand Up @@ -39,6 +40,7 @@ const factorKey = (factor: SignInFactor | null | undefined) => {
};

function SignInFactorOneInternal(): JSX.Element {
const { __internal_setActiveInProgress } = useClerk();
const signIn = useCoreSignIn();
const { preferredSignInStrategy } = useEnvironment().displayConfig;
const availableFactors = signIn.supportedFirstFactors;
Expand Down Expand Up @@ -83,21 +85,27 @@ function SignInFactorOneInternal(): JSX.Element {
const [isPasswordPwned, setIsPasswordPwned] = React.useState(false);

React.useEffect(() => {
if (__internal_setActiveInProgress) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Here's the behavior - right during setActive, this component re-renders with an empty sign-in status:

CleanShot.2025-08-02.at.15.51.36.mp4

return;
}

// Handle the case where a user lands on alternative methods screen,
// clicks a social button but then navigates back to sign in.
// SignIn status resets to 'needs_identifier'
if (signIn.status === 'needs_identifier' || signIn.status === null) {
void router.navigate('../');
}
}, []);
}, [__internal_setActiveInProgress]);

if (!currentFactor && signIn.status) {
return (
if (!currentFactor) {
return signIn.status ? (
<ErrorCard
cardTitle={localizationKeys('signIn.noAvailableMethods.title')}
cardSubtitle={localizationKeys('signIn.noAvailableMethods.subtitle')}
message={localizationKeys('signIn.noAvailableMethods.message')}
/>
) : (
<LoadingCard />
);
}

Expand Down
Loading