Skip to content

Conversation

@alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Jan 30, 2026

Description

  • Introduce <Collapsible /> component
  • Updates <CardAlert /> to use <Collapsible /> to smooth out animations when alerts are shown

BEFORE

before.mov

AFTER

after.mov

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:

Summary by CodeRabbit

  • New Features

    • Added a Collapsible component with smooth height/opacity transitions that respect reduced-motion and theme animation settings.
    • Card alerts now collapse when empty and reveal content only when present, improving visual cleanliness while preserving public behavior.
  • Tests

    • Comprehensive test suite added for the Collapsible covering animations, reduced-motion, mounting/unmounting, inert behavior, and edge cases.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 30, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jan 30, 2026 6:33pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Jan 30, 2026

🦋 Changeset detected

Latest commit: f552f0e

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

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

A new Collapsible component was added. CardAlert now conditionally wraps its Alert in the Collapsible when children are present and no longer applies the previous inline animation or imports. Collapsible animates height, opacity, and a mask-based collapse, respects prefers-reduced-motion and theme appearance settings, and controls mount/unmount timing. Two new appearance keys, `collapsible` and `collapsibleInner`, were added to element descriptors and ElementsConfig. CardAlert’s public signature is unchanged.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 'feat(ui): Add <Collapsible /> component' accurately and concisely describes the primary change: introducing a new Collapsible component to the UI library.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 30, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: f552f0e

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: 1

🤖 Fix all issues with AI agents
In `@packages/ui/src/elements/__tests__/Collapsible.test.tsx`:
- Around line 266-287: The test replaces window.matchMedia with mockMatchMedia
but never restores the original, causing test pollution; update the test to save
the original (e.g., const originalMatchMedia = window.matchMedia) before
overriding, and after the assertion restore it (window.matchMedia =
originalMatchMedia) — preferably wrap the override in a try/finally or move the
restore into an afterEach that checks and resets window.matchMedia so
createFixtures / Collapsible tests don't leak the mocked matchMedia into other
tests.

Comment on lines +266 to +287
it('disables transitions when prefersReducedMotion is true', async () => {
const mockMatchMedia = vi.fn().mockReturnValue({
matches: true,
media: '(prefers-reduced-motion: reduce)',
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
});

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: mockMatchMedia,
});

const { wrapper } = await createFixtures();
const { container } = render(<Collapsible open>Content</Collapsible>, { wrapper });

expect(container.querySelector('.cl-collapsible')).toBeInTheDocument();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Restore window.matchMedia after test to prevent test pollution.

The Object.defineProperty modification to window.matchMedia persists beyond this test since vi.clearAllMocks() only clears mock call history, not property definitions. This can cause flaky behavior in subsequent tests that rely on the real matchMedia.

Proposed fix
 describe('Reduced Motion Handling', () => {
+    let originalMatchMedia: typeof window.matchMedia;
+
+    beforeEach(() => {
+      originalMatchMedia = window.matchMedia;
+    });
+
+    afterEach(() => {
+      Object.defineProperty(window, 'matchMedia', {
+        writable: true,
+        value: originalMatchMedia,
+      });
+    });
+
     it('disables transitions when prefersReducedMotion is true', async () => {
🤖 Prompt for AI Agents
In `@packages/ui/src/elements/__tests__/Collapsible.test.tsx` around lines 266 -
287, The test replaces window.matchMedia with mockMatchMedia but never restores
the original, causing test pollution; update the test to save the original
(e.g., const originalMatchMedia = window.matchMedia) before overriding, and
after the assertion restore it (window.matchMedia = originalMatchMedia) —
preferably wrap the override in a try/finally or move the restore into an
afterEach that checks and resets window.matchMedia so createFixtures /
Collapsible tests don't leak the mocked matchMedia into other tests.

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.

2 participants