-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(tabs): Add role to mat-tab-nav-bar and mat-tab-link #11410
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
Conversation
const fixture = TestBed.createComponent(TabLink); | ||
fixture.detectChanges(); | ||
|
||
const tabList = fixture.debugElement.query(By.css('[role=tablist]')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You query by role=tablist
which means the role must be tablist. Is it better to query by class=mat-tab-links
and check the role?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
ad06f79
to
f3f1676
Compare
LGTM for a11y |
This is already correctly set on the main tab component: https://material.angular.io/components/tabs/overview mat-tab-group has role="tablist" https://github.com/angular/material2/blob/abc3d38c57146443c848d5ba26fd2fab8ca185d6/src/lib/tabs/tab-header.html#L11 mat-tab has role="tab" https://github.com/angular/material2/blob/abc3d38c57146443c848d5ba26fd2fab8ca185d6/src/lib/tabs/tab-group.html#L6 But the standalone version mat-tab-nav-bar and mat-tab-link do not have role set. This is a potential breaking change insofar as someone was already setting role explicitly (test added for this case to verify it doesn't break), but the impact is low and should be rare: I have found no examples on github and only two examples in google3 of role being set, and at worse it sets role="tablist" on mat-tab-nav-bar, which would result in a duplicate role="tablist" nested one layer below, but which is not that harmful and is easy to fix. Existing code that directly sets role on mat-tab-link will have that role overridden, but I don't know that this is currently happening.
f3f1676
to
0064dec
Compare
Thank you! Rebased and ready for further review. |
@stevenyxu FYI this is being reverted in #11657. The nav-tabs follows the pattern of |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This is already correctly set on the main tab component:
https://material.angular.io/components/tabs/overview
mat-tab-group has role="tablist"
https://github.com/angular/material2/blob/abc3d38c57146443c848d5ba26fd2fab8ca185d6/src/lib/tabs/tab-header.html#L11
mat-tab has role="tab"
https://github.com/angular/material2/blob/abc3d38c57146443c848d5ba26fd2fab8ca185d6/src/lib/tabs/tab-group.html#L6
But the standalone version mat-tab-nav-bar and mat-tab-link do not have role set.
This is a potential breaking change insofar as someone was already setting role explicitly (test
added for this case to verify it doesn't break), but the impact is low and should be rare: I have
found no examples on github and only two examples in google3 of role being set, and at worse it sets
role="tablist" on mat-tab-nav-bar, which would result in a duplicate role="tablist" nested one layer
below, but which is not that harmful and is easy to fix. Existing code that directly sets role on
mat-tab-link will have that role overridden, but I don't know that this is currently happening.