Skip to content

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

Merged
merged 1 commit into from
May 30, 2018

Conversation

stevenyxu
Copy link
Contributor

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.

@stevenyxu stevenyxu requested a review from andrewseguin as a code owner May 18, 2018 23:40
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 18, 2018
const fixture = TestBed.createComponent(TabLink);
fixture.detectChanges();

const tabList = fixture.debugElement.query(By.css('[role=tablist]'));
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@tinayuangao
Copy link
Contributor

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.
@stevenyxu
Copy link
Contributor Author

Thank you! Rebased and ready for further review.

@andrewseguin andrewseguin added pr: lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels May 25, 2018
@josephperrott josephperrott merged commit fd23c02 into angular:master May 30, 2018
@jelbourn
Copy link
Member

jelbourn commented Jun 4, 2018

@stevenyxu FYI this is being reverted in #11657. The nav-tabs follows the pattern of nav with anchors by design as opposed to a full tablist pattern.

@stevenyxu
Copy link
Contributor Author

@jelbourn that's fine thank you. nav-tabs is still missing current status indicator. I've adjusted my other PR #11409 to do this.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants