Skip to content

Commit 8a63ace

Browse files
author
Hector Arce De Las Heras
committed
Include new aria-label and aria-labelledby props to checkbox component
1 parent 0f34e07 commit 8a63ace

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/components/checkbox/checkboxStandAlone.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const CheckboxStandAloneComponent = (
4444
helperText,
4545
extraAriaDescribedBy = '',
4646
screenReaderText,
47+
...props
4748
}: ICheckboxStandAlone,
4849
ref: React.ForwardedRef<HTMLInputElement> | undefined | null
4950
): JSX.Element => {
@@ -139,6 +140,8 @@ const CheckboxStandAloneComponent = (
139140
screenReaderId,
140141
})}
141142
aria-invalid={hasError}
143+
aria-label={props['aria-label']}
144+
aria-labelledby={props['aria-labelledby']}
142145
checked={isChecked}
143146
data-testid={`${dataTestId}Input`}
144147
disabled={isDisabled}

src/components/checkbox/types/checkbox.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ export interface ICheckboxErrorStandAlone {
3434
errorMessage?: CheckboxHelperAndErrorTextType;
3535
}
3636

37+
type CheckboxAriaAttributes = Pick<React.AriaAttributes, 'aria-label' | 'aria-labelledby'>;
38+
3739
/**
3840
* @description
3941
* interface for the checkbox standAlone
4042
*/
41-
export interface ICheckboxStandAlone extends IInputComponent {
43+
export interface ICheckboxStandAlone extends IInputComponent, CheckboxAriaAttributes {
4244
dataTestId?: string;
4345
state: CheckboxStateType;
4446
styles?: CheckboxPropsStylesType;

src/components/checkboxWithLabel/checkboxWithLabelStandAlone.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ const CheckboxWithLabelStandAloneComponent = <V extends string | unknown>(
5151
styles={styles}
5252
>
5353
<CheckboxControlled
54+
aria-label={props['aria-label']}
55+
aria-labelledby={props['aria-labelledby']}
5456
checked={checked}
5557
checkedIcon={checkedIcon}
5658
dataTestId={dataTestId}

0 commit comments

Comments
 (0)