Skip to content

Commit

Permalink
Cpatil/added rest props for checkbox and radio components (#928)
Browse files Browse the repository at this point in the history
* fix: added condition for role attribute in checkboxgroup and radiogroup components

* fix: added rest props in checkbox and radiobutton components

* fix: added null check for items length
  • Loading branch information
cpatil-c-eightfold authored Jan 6, 2025
1 parent 64519fb commit 2d6741d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/CheckBox/CheckBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const CheckBox: FC<CheckboxProps> = React.forwardRef(
value,
variant = SelectorVariant.Default,
'data-test-id': dataTestId,
...rest
},
ref: Ref<HTMLInputElement>
) => {
Expand Down Expand Up @@ -208,6 +209,7 @@ export const CheckBox: FC<CheckboxProps> = React.forwardRef(
value={value}
readOnly
role={toggle ? 'switch' : 'checkbox'}
{...rest}
/>
<label htmlFor={checkBoxId.current} className={labelClassNames}>
{labelPosition == LabelPosition.Start && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/CheckBox/CheckBoxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const CheckBoxGroup: FC<CheckboxGroupProps> = React.forwardRef(
<div
className={checkboxGroupClassNames}
style={style}
role="group"
role={items?.length > 1 ? 'group' : undefined}
aria-label={ariaLabel}
id={id}
ref={ref}
Expand Down
2 changes: 2 additions & 0 deletions src/components/RadioButton/RadioButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const RadioButton: FC<RadioButtonProps> = React.forwardRef(
value = '',
variant = SelectorVariant.Default,
'data-test-id': dataTestId,
...rest
},
ref: Ref<HTMLInputElement>
) => {
Expand Down Expand Up @@ -195,6 +196,7 @@ export const RadioButton: FC<RadioButtonProps> = React.forwardRef(
value={value}
onChange={!allowDisabledFocus ? toggleChecked : null}
readOnly
{...rest}
/>
<label htmlFor={radioButtonId.current} className={labelClassNames}>
{labelPosition == LabelPosition.Start && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/RadioButton/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const RadioGroup: FC<RadioGroupProps> = React.forwardRef(
return (
<RadioGroupProvider onChange={onChange} value={value}>
<div
role="group"
role={items.length > 1 ? 'group' : undefined}
className={radioGroupClasses}
style={style}
ref={ref}
Expand Down

0 comments on commit 2d6741d

Please sign in to comment.