Skip to content

Conversation

@dstaley
Copy link
Member

@dstaley dstaley commented May 23, 2025

Description

This PR fixes an issue where the combined flow wouldn't trigger correctly when invoked with a phone number while phone number was an optional field. It resolves the issue by treating phone_number as a non-optional field when a phone number identifier is used. Additionally, it adds some very, very basic unit tests for the handleCombinedFlowTransfer function.

For context, we don't automatically convert sign ins to sign ups in the combined flow if there are possible optional fields that the user might want to complete. Before this PR, phone_number was an optional field. If the user tried to sign in with a phone number not associated with an account, we would consider phone_number an optional field, and redirect to the create step. This was unnecessary since the user already provided a phone number.

Fixes SDKI-1020

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot
Copy link

changeset-bot bot commented May 23, 2025

🦋 Changeset detected

Latest commit: f78f00f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

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

@vercel
Copy link

vercel bot commented May 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 23, 2025 5:12pm

@dstaley dstaley requested a review from Copilot May 23, 2025 16:58
@pkg-pr-new
Copy link

pkg-pr-new bot commented May 23, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@5992

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@5992

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@5992

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@5992

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@5992

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@5992

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@5992

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@5992

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@5992

@clerk/express

npm i https://pkg.pr.new/@clerk/express@5992

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@5992

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@5992

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@5992

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@5992

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@5992

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@5992

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@5992

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@5992

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@5992

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@5992

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@5992

@clerk/types

npm i https://pkg.pr.new/@clerk/types@5992

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@5992

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@5992

commit: f78f00f

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures the combined sign-up flow correctly handles phone numbers when they’re marked optional and adds basic unit tests for the handleCombinedFlowTransfer function.

  • Extend hasOptionalFields to accept identifierAttribute and ignore phone_number when phoneNumber is used as the identifier.
  • Update the combined flow transfer logic to call the new hasOptionalFields signature.
  • Add unit tests covering phone-number identifier flows and basic hasOptionalFields behavior.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/clerk-js/src/ui/components/SignIn/handleCombinedFlowTransfer.ts Update optional-fields logic to consider identifierAttribute, export hasOptionalFields, and skip phone_number when appropriate.
packages/clerk-js/src/ui/components/SignIn/tests/handleCombinedFlowTransfer.test.ts Add tests for phone-number identifier, passwordEnabled, username cases, and hasOptionalFields scenarios.
.changeset/little-wings-bathe.md Add patch changeset describing the fix for treating phone_number as required when used as an identifier.
Comments suppressed due to low confidence (3)

packages/clerk-js/src/ui/components/SignIn/tests/handleCombinedFlowTransfer.test.ts:151

  • Add a test case to verify that hasOptionalFields excludes 'email_address' when identifierAttribute is 'emailAddress'.
describe('hasOptionalFields', () => {

packages/clerk-js/src/ui/components/SignIn/tests/handleCombinedFlowTransfer.test.ts:151

  • Add tests to ensure fields starting with 'oauth_' or 'web3_', and values 'enterprise_sso'/'saml', are properly filtered out.
describe('hasOptionalFields', () => {

packages/clerk-js/src/ui/components/SignIn/handleCombinedFlowTransfer.ts:113

  • Also exclude 'email_address' when identifierAttribute is 'emailAddress' to ensure email identifiers aren’t counted as optional and don’t block the direct flow.
// If a phone number is used as the identifier, we don't need to consider the phone_number field.

Copy link
Member

@brkalow brkalow left a comment

Choose a reason for hiding this comment

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

👏

@brkalow brkalow merged commit ac4f31c into main May 28, 2025
38 checks passed
@brkalow brkalow deleted the dylan/sdki-1020-sign-up-not-being-immediately-submitted-when-phone-number-is branch May 28, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants