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

added aria label prop and attribute to checkbox #3906

Merged
merged 8 commits into from Nov 18, 2020
6 changes: 6 additions & 0 deletions documentation-site/components/yard/config/checkbox.ts
Expand Up @@ -131,6 +131,12 @@ const CheckboxConfig: TConfig = {
description: 'Title attribute.',
hidden: true,
},
ariaLabel: {
value: undefined,
type: PropTypes.String,
description: 'Aria-label attribute',
hidden: true,
},
...pick(changeHandlers, [
'onBlur',
'onFocus',
Expand Down
2 changes: 2 additions & 0 deletions src/checkbox/checkbox.js
Expand Up @@ -133,6 +133,7 @@ class StatelessCheckbox extends React.Component<PropsT, StatelessStateT> {
children,
required,
title,
ariaLabel
} = this.props;

const {
Expand Down Expand Up @@ -228,6 +229,7 @@ class StatelessCheckbox extends React.Component<PropsT, StatelessStateT> {
name={name}
checked={checked}
required={required}
aria-label={ariaLabel}
aria-checked={isIndeterminate ? 'mixed' : checked}
aria-describedby={this.props['aria-describedby']}
aria-errormessage={this.props['aria-errormessage']}
Expand Down
1 change: 1 addition & 0 deletions src/checkbox/index.d.ts
Expand Up @@ -103,6 +103,7 @@ export interface CheckboxProps {
labelPlacement?: 'top' | 'right' | 'bottom' | 'left';
checkmarkType?: STYLE_TYPE[keyof STYLE_TYPE];
title?: string;
ariaLabel?: string;
onChange?: React.FormEventHandler<HTMLInputElement>;
onMouseEnter?: React.MouseEventHandler<HTMLInputElement>;
onMouseLeave?: React.MouseEventHandler<HTMLInputElement>;
Expand Down
2 changes: 2 additions & 0 deletions src/checkbox/types.js
Expand Up @@ -46,6 +46,8 @@ export type PropsT = {
'aria-describedby'?: string,
/** Id of element which contains a related error message */
'aria-errormessage'?: string,
/** Passed to the input element aria-label attribute. */
ariaLabel?: string,
/** Component or String value for label of checkbox. */
children?: React$Node,
overrides?: OverridesT,
Expand Down