Skip to content

Commit 8709f20

Browse files
authored
fix: prevent console warning in checkbox & radio (#10048)
1 parent f62813f commit 8709f20

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/react-core/src/components/Checkbox/Checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
137137
const labelRendered = label ? (
138138
<Label
139139
className={css(styles.checkLabel, isDisabled && styles.modifiers.disabled)}
140-
htmlFor={!wrapWithLabel && props.id}
140+
htmlFor={!wrapWithLabel ? props.id : undefined}
141141
>
142142
{label}
143143
{isRequired && (
@@ -154,7 +154,7 @@ class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
154154
return (
155155
<Component
156156
className={css(styles.check, !label && styles.modifiers.standalone, className)}
157-
htmlFor={wrapWithLabel && props.id}
157+
htmlFor={wrapWithLabel ? props.id : undefined}
158158
>
159159
{isLabelBeforeButton ? (
160160
<>

packages/react-core/src/components/Radio/Radio.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Radio extends React.Component<RadioProps, { ouiaStateId: string }> {
119119
const labelRendered = label ? (
120120
<Label
121121
className={css(styles.radioLabel, isDisabled && styles.modifiers.disabled)}
122-
htmlFor={!wrapWithLabel && props.id}
122+
htmlFor={!wrapWithLabel ? props.id : undefined}
123123
>
124124
{label}
125125
</Label>
@@ -130,7 +130,7 @@ class Radio extends React.Component<RadioProps, { ouiaStateId: string }> {
130130
return (
131131
<Component
132132
className={css(styles.radio, !label && styles.modifiers.standalone, className)}
133-
htmlFor={wrapWithLabel && props.id}
133+
htmlFor={wrapWithLabel ? props.id : undefined}
134134
>
135135
{isLabelBeforeButton ? (
136136
<>

0 commit comments

Comments
 (0)