<SignIn />: first "Use email" click switches back to phone when `initialValues.phoneNumber` is set

未關閉 適合新手
#10,487 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@twicestruck 已經在處理了。

開始於 2026年10月28日。

  • #10488 來自 @twicestruck —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
74/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
react, typescript

研究方向

從 packages/ui/src/components/SignIn/SignInStart.tsx 開始,特別查看 textIdentifierField 的初始化,以及 issue 中描述的自動填入 effect。追蹤點擊「使用電子郵件」時與 handlePhoneNumberPaste 的互動;重現連結可用來確認此行為。完成條件是:第一次點擊後顯示預先填入電話號碼的電子郵件欄位,且有回歸測試涵蓋此情況。

由索引模型根據 Issue 內容生成。

描述

Preliminary Checks
Reproduction

https://github.com/twicestruck/clerk-signin-phone-prefill-repro

Publishable key

pk_test_ZXhwZXJ0LXVuaWNvcm4tNzgyOC5jbGVyay5hY2NvdW50cy5kZXYk

Description

With email and phone both enabled as sign-in identifiers, <SignIn initialValues={{ phoneNumber: '+15555550100' }} /> opens on the phone field as expected, but the first "Use email" click switches straight back to the phone field. The second click works.

Steps to reproduce:

  1. Run the reproduction with the publishable key above
  2. Click "Use email" once

Expected behavior:

The email field shows.

Actual behavior:

The form switches back to the phone field.

Cause: when the form starts on the phone field, SignInStart seeds textIdentifierField with initialValues[identifierAttribute], which is the phone number (source). After the switch, the autofill effect sees a value starting with + and calls handlePhoneNumberPaste, which switches back to the phone field and clears the email field, so the second click sticks. A prefilled number without + shows up in the email field instead.

I'll open a PR with a fix and a test.

Environment
System:
  OS: macOS 27.0.1
  CPU: (18) arm64 Apple M5 Max
  Memory: 157.16 MB / 36.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 24.22.0
  npm: 11.19.1
  pnpm: 12.14.0
  bun: 1.4.3
Browsers:
  Brave Browser: 155.1.97.59
  Chrome: 155.0.8059.85
  Chrome Canary: 158.0.8110.0
  Firefox: 158.0
  Safari: 27.0.1
npmPackages:
  @clerk/react: 6.18.3 => 6.18.3
  @vitejs/plugin-react: 6.1.2 => 6.1.2
  react: 19.3.1 => 19.3.1
  react-dom: 19.3.1 => 19.3.1
  vite: 8.3.5 => 8.3.5
主要語言
TypeScript
星號
1.8k
分支
484
平均合併
1 天 7 小時
30 天內合併 PR
350

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

clerk/javascript 的其他 Issue

查看 clerk/javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。