Skip to content

fix(Alert): forward consumer className instead of overwriting it#1147

Merged
DreaminDani merged 1 commit into
mainfrom
fix/alert-classname-forwarding
Jul 7, 2026
Merged

fix(Alert): forward consumer className instead of overwriting it#1147
DreaminDani merged 1 commit into
mainfrom
fix/alert-classname-forwarding

Conversation

@DreaminDani

Copy link
Copy Markdown
Contributor

Problem

Alert silently discards any className a consumer passes — including the class generated by styled(Alert) and any plain <Alert className="…">. The root element spread {...delegated} and then applied className={cn(wrapperVariants(...))}, unconditionally overwriting the incoming value.

This is a regression from the CSS Modules migration: the previous styled-components implementation merged the consumer className automatically.

Fix

  • Destructure className out of the rest props and merge it into cn(...) on the root: className={cn(wrapperVariants({ state, type }), className)}.
  • Declare className?: string on AlertProps so it's a supported, typed prop.
  • Add a regression test asserting a passed className lands on the root alongside the base class (not replacing it).

Verification

  • yarn test src/components/Alert/Alert.test.tsx — 3 passed (incl. new regression test)
  • yarn format — clean
  • eslint on changed files — clean
  • No behavior change beyond className forwarding.

Note: a pre-existing yarn typecheck error in DatePicker/Common.tsx (from the @h6s/calendar 2.2.0 bump on main) is unrelated to this change and out of scope here.

🤖 Generated with Claude Code

The root element spread {...delegated} and then set className={cn(...)},
which overwrote any consumer-provided className — including the class
generated by styled(Alert). Merge the incoming className into cn() and
declare it as a supported prop.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2b56b07

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

This PR includes changesets to release 1 package
Name Type
@clickhouse/click-ui 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

Comment thread src/components/Alert/Alert.test.tsx
@workflow-authentication-public

Copy link
Copy Markdown
Contributor

Storybook Preview Deployed

✅ Preview URL: https://click-qij289znf-clickhouse.vercel.app

Built from commit: 25ef9da387b3b44ede6dbe0630e3549c875e3053

@DreaminDani DreaminDani merged commit 97859e9 into main Jul 7, 2026
11 checks passed
@DreaminDani DreaminDani deleted the fix/alert-classname-forwarding branch July 7, 2026 22:43
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.

2 participants