Skip to content

fix(ui): hide unavailable alternative verification methods - #9355

Merged
tmilewski merged 3 commits into
mainfrom
tom/hide-unavailable-alternative-verification-methods
Aug 7, 2026
Merged

fix(ui): hide unavailable alternative verification methods#9355
tmilewski merged 3 commits into
mainfrom
tom/hide-unavailable-alternative-verification-methods

Conversation

@tmilewski

Copy link
Copy Markdown
Member

Summary

  • hide “Use another method” during Device Trust verification when only one factor is available
  • apply the same behavior to regular second-factor verification
  • add status-accurate component coverage and a Device Trust integration assertion

Root cause

The Device Trust and second-factor containers always passed an alternative-method callback to their verification cards. The cards use the callback’s presence to decide whether to render the action, so the link appeared even when there was no alternative factor.

Impact

Users no longer see a dead-end “Use another method” action when only one verification factor is available. The action remains visible when multiple factors exist.

Validation

  • pnpm --filter @clerk/ui exec vitest run src/components/SignIn/__tests__/SignInClientTrust.test.tsx src/components/SignIn/__tests__/SignInFactorTwo.test.tsx
  • E2E_APP_ID=next.appRouter.withNeedsClientTrust pnpm playwright test --config integration/playwright.config.ts integration/tests/client-trust.test.ts
  • pnpm --filter @clerk/ui format:check
  • targeted ESLint (0 errors)
  • pnpm turbo build --filter=@clerk/ui

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview Aug 7, 2026 3:34am
swingset Ready Ready Preview Aug 7, 2026 3:34am

Request Review

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0be5443

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

This PR includes changesets to release 3 packages
Name Type
@clerk/ui Patch
@clerk/chrome-extension Patch
@clerk/swingset 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

@tmilewski

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 08a72ed2d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: da073c26-e0c3-4287-9de3-a47a68f18635

📥 Commits

Reviewing files that changed from the base of the PR and between 08a72ed and c2d5f03.

📒 Files selected for processing (1)
  • packages/ui/src/components/SignIn/__tests__/SignInFactorTwo.test.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)
  • clerk/clerk-ios (auto-detected)
  • clerk/clerk-android (auto-detected)
  • clerk/cli (auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/ui/src/components/SignIn/tests/SignInFactorTwo.test.tsx

📝 Walkthrough

Walkthrough

Sign-in Device Trust and second-factor flows now pass the “Use another method” handler only when multiple verification factors are supported. The backup-code card accepts an optional handler. Test fixtures now support shared second-factor and client-trust setup, including email-code verification. Unit and integration tests cover hidden and visible alternative-method states. A patch changeset documents the behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: wobsoriano

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes hiding unavailable alternative verification methods, which is the main change.
Description check ✅ Passed The description accurately explains the behavior change, root cause, impact, and validation for Device Trust and second-factor verification.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/ui/src/components/SignIn/__tests__/SignInFactorTwo.test.tsx (1)

410-419: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a visible-state test for SignInFactorTwo.

This test covers only one supported factor. Add a second case with supportPhoneCode: true and supportEmailCode: true, then assert that Use another method is present. The positive test in SignInClientTrust.test.tsx does not verify the regular second-factor wiring in SignInFactorTwo.tsx.

As per coding guidelines, unit tests are required for all new functionality and must verify behavior and edge cases.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ui/src/components/SignIn/__tests__/SignInFactorTwo.test.tsx` around
lines 410 - 419, Add a second test alongside the existing single-factor case in
the SignInFactorTwo test suite, configuring startSignInFactorTwo with both
supportPhoneCode and supportEmailCode enabled. After preparing the second factor
and rendering SignInFactorTwo, assert that “Use another method” is visible,
covering the regular two-factor wiring.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ui/src/test/fixture-helpers.ts`:
- Line 224: Add a stable emailAddressId field to the email-code fixture object
created in fixture-helpers.ts, so SignInFactorTwoEmailCodeCard can pass it to
prepareSecondFactor when selecting the supportEmailCode factor. Preserve the
existing strategy and safe_identifier values.

---

Nitpick comments:
In `@packages/ui/src/components/SignIn/__tests__/SignInFactorTwo.test.tsx`:
- Around line 410-419: Add a second test alongside the existing single-factor
case in the SignInFactorTwo test suite, configuring startSignInFactorTwo with
both supportPhoneCode and supportEmailCode enabled. After preparing the second
factor and rendering SignInFactorTwo, assert that “Use another method” is
visible, covering the regular two-factor wiring.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 6039a61b-f86a-4f23-90ee-292367704787

📥 Commits

Reviewing files that changed from the base of the PR and between 2f24826 and 08a72ed.

📒 Files selected for processing (8)
  • .changeset/tidy-device-trust-methods.md
  • integration/tests/client-trust.test.ts
  • packages/ui/src/components/SignIn/SignInClientTrust.tsx
  • packages/ui/src/components/SignIn/SignInFactorTwo.tsx
  • packages/ui/src/components/SignIn/SignInFactorTwoBackupCodeCard.tsx
  • packages/ui/src/components/SignIn/__tests__/SignInClientTrust.test.tsx
  • packages/ui/src/components/SignIn/__tests__/SignInFactorTwo.test.tsx
  • packages/ui/src/test/fixture-helpers.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)
  • clerk/clerk-ios (auto-detected)
  • clerk/clerk-android (auto-detected)
  • clerk/cli (auto-detected)

Comment thread packages/ui/src/test/fixture-helpers.ts

@wobsoriano wobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🫰

@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9355

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9355

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9355

@clerk/expo

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

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9355

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9355

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9355

@clerk/upgrade

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

@clerk/vue

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

commit: 0be5443

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-07T03:34:31.083Z

Summary

Metric Count
Packages analyzed 19
Packages with changes 0
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 0

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on 0be5443.

@tmilewski
tmilewski enabled auto-merge (squash) August 7, 2026 03:37
@tmilewski
tmilewski merged commit 60a9c71 into main Aug 7, 2026
52 checks passed
@tmilewski
tmilewski deleted the tom/hide-unavailable-alternative-verification-methods branch August 7, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants