Skip to content

Commit

Permalink
[FormLabel] use aria-hidden on required asterisk
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Lorek committed Apr 24, 2020
1 parent 2231349 commit 6550f53
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/material-ui/src/FormLabel/FormLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const FormLabel = React.forwardRef(function FormLabel(props, ref) {
{children}
{fcs.required && (
<span
aria-hidden
className={clsx(classes.asterisk, {
[classes.error]: fcs.error,
})}
Expand Down
2 changes: 2 additions & 0 deletions packages/material-ui/src/FormLabel/FormLabel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('<FormLabel />', () => {

expect(container.querySelector('label')).to.have.text('name\u2009*');
expect(container.querySelectorAll(`.${classes.asterisk}`)).to.have.lengthOf(1);
expect(container.querySelectorAll(`.${classes.asterisk}`)[0]).toBeAriaHidden();
});

it('should not show an asterisk by default', () => {
Expand All @@ -48,6 +49,7 @@ describe('<FormLabel />', () => {

expect(container.querySelectorAll(`.${classes.asterisk}`)).to.have.lengthOf(1);
expect(container.querySelector(`.${classes.asterisk}`)).to.have.class(classes.error);
expect(container.querySelectorAll(`.${classes.asterisk}`)[0]).toBeAriaHidden();
expect(container.firstChild).to.have.class(classes.error);
});
});
Expand Down

0 comments on commit 6550f53

Please sign in to comment.