Skip to content

Add onClose cb and playground colors#20

Merged
josephdburdick merged 2 commits into
mainfrom
feat/add-onClose
Apr 30, 2026
Merged

Add onClose cb and playground colors#20
josephdburdick merged 2 commits into
mainfrom
feat/add-onClose

Conversation

@josephdburdick
Copy link
Copy Markdown
Contributor

@josephdburdick josephdburdick commented Apr 30, 2026

Summary by CodeRabbit

  • New Features
    • Drawer now supports a close callback so integrations can react when a drawer finishes closing.
  • Styling
    • Drawer content background and shadow are centralized into a shared slots configuration for consistent, easier customization.
  • Tests
    • Added tests verifying close-callback behavior across open/close scenarios.
  • Refactor
    • Improved initialization flow for style-merge utilities for more predictable behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 097ddc2e-d89d-4afa-9acd-280351fbb403

📥 Commits

Reviewing files that changed from the base of the PR and between 552533d and af74279.

📒 Files selected for processing (1)
  • src/components/Drawer.test.tsx

📝 Walkthrough

Walkthrough

Adds a shared playground drawer slot for content styling, exposes a new onClose Drawer prop invoked when open transitions true→false, removes hardcoded background/shadow defaults from DrawerContent, and changes tailwind-merge initialization to run at module import time.

Changes

Cohort / File(s) Summary
Drawer core & types
src/components/Drawer.tsx, src/types.ts, src/components/drawer/DrawerContent.tsx
Adds optional onClose?: () => void to Drawer props and invokes it when controlled open goes true→false. Removes hardcoded bg-white and bottom shadow from DrawerContent defaults so slots/props control styling.
Playground wiring
playground/src/PlaygroundApp.tsx
Adds playgroundDrawerSlots with contentClassName: 'bg-white' and passes slots={playgroundDrawerSlots} to all Playground Drawer instances.
Utility init behavior
src/utils.ts
Moves tailwind-merge initialization to eager module-load (ensureTwMergeInit() called at import). Removes isTwMergeInitialized boolean and related .finally tracking; cn() still falls back to clsx until init resolves.
Tests
src/components/Drawer.test.tsx
Adds tests asserting onClose fires exactly once on true→false transitions (controlled and uncontrolled overlay close scenarios).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped in to tweak the drawer's hue,
White moved to slots, no defaults to glue.
A gentle "onClose" whispers when it parts,
Tailwind wakes early, eager at start.
Hop, click, drawer—my code plays its part.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: adding an onClose callback and centralizing playground drawer colors/styling.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-onClose

Review rate limit: 0/3 reviews remaining, refill in 50 minutes and 32 seconds.

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

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
src/components/Drawer.tsx (1)

93-99: ⚡ Quick win

Add regression tests for onClose transition semantics.

Please lock this behavior with tests for: (1) no call on initial open=false mount, and (2) exactly one call on true → false in both controlled and uncontrolled flows.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Drawer.tsx` around lines 93 - 99, Add regression tests for
Drawer to assert onClose transition semantics: create tests referencing the
Drawer component and its props (open, onCloseProp) and the internal
wasOpenRef/useEffect behavior by (1) rendering Drawer with open={false} on
initial mount and asserting onClose mock (jest.fn) is not called, and (2)
asserting exactly one onClose call when changing from open=true to open=false in
both controlled (pass open prop and rerender to false) and uncontrolled flows
(render without open, simulate the user or prop path that closes the drawer) by
using react-testing-library render/rerender (or fireEvent) inside act and
verifying mock calls === 1. Ensure tests use rerender or user events to trigger
the transition true → false and explicitly assert no extra calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/components/Drawer.tsx`:
- Around line 93-99: Add regression tests for Drawer to assert onClose
transition semantics: create tests referencing the Drawer component and its
props (open, onCloseProp) and the internal wasOpenRef/useEffect behavior by (1)
rendering Drawer with open={false} on initial mount and asserting onClose mock
(jest.fn) is not called, and (2) asserting exactly one onClose call when
changing from open=true to open=false in both controlled (pass open prop and
rerender to false) and uncontrolled flows (render without open, simulate the
user or prop path that closes the drawer) by using react-testing-library
render/rerender (or fireEvent) inside act and verifying mock calls === 1. Ensure
tests use rerender or user events to trigger the transition true → false and
explicitly assert no extra calls.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: eadadf64-488a-4f8e-b259-8402745bd2ee

📥 Commits

Reviewing files that changed from the base of the PR and between 235ecf6 and 552533d.

📒 Files selected for processing (5)
  • playground/src/PlaygroundApp.tsx
  • src/components/Drawer.tsx
  • src/components/drawer/DrawerContent.tsx
  • src/types.ts
  • src/utils.ts

@josephdburdick josephdburdick merged commit 84caeb5 into main Apr 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant