fix(Alert): forward consumer className instead of overwriting it#1147
Merged
Conversation
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 detectedLatest commit: 2b56b07 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
DreaminDani
commented
Jul 7, 2026
Contributor
Storybook Preview Deployed✅ Preview URL: https://click-qij289znf-clickhouse.vercel.app Built from commit: |
ariser
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Alertsilently discards anyclassNamea consumer passes — including the class generated bystyled(Alert)and any plain<Alert className="…">. The root element spread{...delegated}and then appliedclassName={cn(wrapperVariants(...))}, unconditionally overwriting the incoming value.This is a regression from the CSS Modules migration: the previous styled-components implementation merged the consumer
classNameautomatically.Fix
classNameout of the rest props and merge it intocn(...)on the root:className={cn(wrapperVariants({ state, type }), className)}.className?: stringonAlertPropsso it's a supported, typed prop.classNamelands 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— cleaneslinton changed files — cleanNote: a pre-existing
yarn typecheckerror inDatePicker/Common.tsx(from the@h6s/calendar2.2.0 bump onmain) is unrelated to this change and out of scope here.🤖 Generated with Claude Code