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/large-rockets-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': minor
---

The sign-in form will now switch to the phone input if the only initial value provided was that of the phone number.
9 changes: 8 additions & 1 deletion packages/clerk-js/src/ui/components/SignIn/SignInStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ export function _SignInStart(): JSX.Element {
() => groupIdentifiers(userSettings.enabledFirstFactorIdentifiers),
[userSettings.enabledFirstFactorIdentifiers],
);
const [identifierAttribute, setIdentifierAttribute] = useState<SignInStartIdentifier>(identifierAttributes[0] || '');

const onlyPhoneNumberInitialValueExists =
!!ctx.initialValues?.phoneNumber && !(ctx.initialValues.emailAddress || ctx.initialValues.username);
const shouldStartWithPhoneNumberIdentifier =
onlyPhoneNumberInitialValueExists && identifierAttributes.includes('phone_number');
const [identifierAttribute, setIdentifierAttribute] = useState<SignInStartIdentifier>(
shouldStartWithPhoneNumberIdentifier ? 'phone_number' : identifierAttributes[0] || '',
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🙃 instead of using phone_number hard coded string, could we use PhoneNumberIdentifier from @clerk/types?

const [hasSwitchedByAutofill, setHasSwitchedByAutofill] = useState(false);

const organizationTicket = getClerkQueryParam('__clerk_ticket') || '';
Expand Down