Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(form-label/helper-text): fix merging of classname not working properly when inside a FormControl #2156

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/witty-icons-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@channel.io/bezier-react": patch
---

Fixes an issue where injecting `className` into `FormLabel`, `FormHelperText` inside a `FormControl` does not apply styles correctly.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const FORM_ERROR_MESSAGE_TEST_ID = 'bezier-form-error-message'

const BaseHelperText = forwardRef<HTMLSpanElement, BaseHelperTextProps>(
function BaseHelperText(props, forwardedRef) {
const { type, typo = '13', children, ...rest } = props
const { type, typo = '13', children, className, ...rest } = props

const contextValue = useFormControlContext()
const getProps =
Expand Down Expand Up @@ -52,7 +52,11 @@ const BaseHelperText = forwardRef<HTMLSpanElement, BaseHelperTextProps>(
<Text
ref={mergedRef}
as="p"
className={classNames(styles.FormHelperText, formControlClassName)}
className={classNames(
styles.FormHelperText,
formControlClassName,
className
)}
typo={typo}
align="left"
{...ownProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const FormLabel = forwardRef<HTMLLabelElement, FormLabelProps>(
help,
bold = true,
color = 'txt-black-darkest',
className,
children,
...rest
} = props
Expand Down Expand Up @@ -67,7 +68,8 @@ export const FormLabel = forwardRef<HTMLLabelElement, FormLabelProps>(
<Text
className={classNames(
styles.LabelText,
!HelpComponent && formControlClassName
!HelpComponent && formControlClassName,
className
)}
ref={forwardedRef}
as="label"
Expand All @@ -91,7 +93,7 @@ export const FormLabel = forwardRef<HTMLLabelElement, FormLabelProps>(
<LegacyHStack
align="center"
spacing={6}
className={HelpComponent && formControlClassName}
className={formControlClassName}
>
<LegacyStackItem
shrink
Expand Down