Skip to content

Conversation

@alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Oct 28, 2025

Description

Hides last use badge from rendering when only one strategy is enabled.

BEFORE AFTER
Screenshot 2025-10-28 at 10 46 25 AM Screenshot 2025-10-28 at 10 45 50 AM

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 Oct 28, 2025

🦋 Changeset detected

Latest commit: cd22133

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 Oct 28, 2025

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

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Oct 29, 2025 2:37pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

A patch release for @clerk/clerk-js adds conditional logic to display the last authentication strategy badge only when multiple strategies are available. The SocialButtons component now checks if more than one strategy exists before rendering the last used strategy indicator.

Changes

Cohort / File(s) Summary
Release documentation
.changeset/hot-clowns-yell.md
Changelog entry for patch release documenting UI behavior: last use strategy badge renders only when a last used strategy exists and multiple strategies are enabled
Social button UI logic
packages/clerk-js/src/ui/elements/SocialButtons.tsx
Introduces shouldShowLastAuthenticationStrategy guard based on strategies.length > 1. Conditionally passes lastAuthenticationStrategy (or null) to ButtonElement and SocialButtonIcon/SocialButtonBlock rendering paths only when the guard evaluates true

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Focused change with straightforward conditional logic applied consistently across the file
  • Single guard condition with repetitive application pattern (minimal reasoning variance)
  • Only two files affected; no complex interdependencies or behavioral edge cases evident

Poem

🐰 When strategies align and multiply with care,
Show the badge of last use—if more than one's there!
A simple condition, yet elegant and true,
One guard to guide them, a /\✨ clean breakthrough!

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix(clerk-js): Add length check to rendering lastAuthenticationStrategy" directly corresponds to the main changes in the pull request. The changeset introduces a guard shouldShowLastAuthenticationStrategy based on strategies.length > 1, which controls whether the lastAuthenticationStrategy badge is rendered. The title accurately summarizes this core change with appropriate specificity and clarity, using the conventional commit format to indicate a bug fix. A developer scanning git history would understand that this PR adds conditional logic to only render the lastAuthenticationStrategy badge when multiple strategies are present.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch alexcarpenter/lastAuthenticationStrategy-length

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/hot-clowns-yell.md (1)

5-5: Optional: Minor wording consistency.

Consider revising for consistency: "Only render last used strategy badge..." (currently says "last use").

Additionally, compound adjectives like "last-used" are typically hyphenated when modifying a noun, though this is a minor stylistic preference.

Apply this diff for improved consistency:

-Only render last use strategy badge when there is a last used strategy available and there is more than one strategy enabled.
+Only render last-used strategy badge when there is a last-used strategy available and there is more than one strategy enabled.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 76ac49d and d1c7939.

📒 Files selected for processing (2)
  • .changeset/hot-clowns-yell.md (1 hunks)
  • packages/clerk-js/src/ui/elements/SocialButtons.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
packages/clerk-js/src/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)

packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure

Files:

  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: UserProfile, NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...

Files:

  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering

Files:

  • packages/clerk-js/src/ui/elements/SocialButtons.tsx
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/hot-clowns-yell.md
🧬 Code graph analysis (1)
packages/clerk-js/src/ui/elements/SocialButtons.tsx (1)
packages/clerk-js/src/ui/elements/utils.ts (1)
  • distributeStrategiesIntoRows (7-54)
🪛 LanguageTool
.changeset/hot-clowns-yell.md

[grammar] ~5-~5: Use a hyphen to join words.
Context: ... use strategy badge when there is a last used strategy available and there is mor...

(QB_NEW_EN_HYPHEN)

🔇 Additional comments (3)
packages/clerk-js/src/ui/elements/SocialButtons.tsx (3)

83-83: LGTM! Correct guard logic.

The condition strategies.length > 1 correctly ensures the badge only appears when there are multiple strategies to choose from. With a single strategy, displaying "last used" provides no value since there's no alternative.


84-88: LGTM! Consistent conditional propagation.

Passing null when shouldShowLastAuthenticationStrategy is false correctly prevents distributeStrategiesIntoRows from treating a single strategy as "last used". The function handles null gracefully per its signature.


198-200: LGTM! Correct conditional badge rendering.

The compound condition ensures the badge only renders when both:

  1. Multiple strategies are available (shouldShowLastAuthenticationStrategy)
  2. This button represents the last used strategy (strategy === lastAuthenticationStrategy)

This correctly implements the desired behavior throughout the component tree.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 29, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: cd22133

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.

4 participants