-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Add ARIA roles and labelledby to branch dropdown tabs #17172
Conversation
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.
This is working as expected. 💖
This could have been solved in other ways by adding parent div elements inside of the BranchesContainer component, that contained the correct role="tabpanel" and aria-labelledby attributes. However, I think there is a benefit to the commonly used FilterList and SectionFilterList components being able to have different ARIA attributes depending on the parent components usage of the properties.
I think I prefer that solution. Reason being is, in this particular scenario, the list is only contents of the tabpanel
, but technically someday we may decide to add more controls to this tab and then this would need refactored. Also, is not a common pattern for a list itself to be a tabpanel
nor have a role placed on it's parent container. The list itself may and that is already handled in the list component, but not the container. Another smaller concern is that the addition of props like this makes it seem like it is a reasonable expectation to provide an aria-labelledby
to a list container which is only WCAG correct if that div has a role added to it that also requires a label association. In this use case, that is true, but we are opening the props up to any combination of usage.. which could lead a future developer to a mistake since "it can" accept it.
Does that make sense?
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.
This is looking great! Thank you for that change.
One small nit I promise then we can get it merged.
What do you think about reducing some of the reused logic and have a method like:
private renderSelectedTab() {
const { selectedTab, repository } = this.props
const ariaLabelledBy =
selectedTab === BranchesTab.Branches || !repository.gitHubRepository
? 'branches-tab'
: 'pull-requests-tab'
return (
<div
role="tabpanel"
aria-labelledby={ariaLabelledBy}
className="branches-container-panel"
>
{this.renderSelectedTabContent()}
</div>
)
}
and rename the current renderSelectedTab
to renderSelectedTabContent
?
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.
✨ Thank you again for the change. 🙏 LGTM!
References:
Description
When opening the branches dropdown, focus is automatically shifted to the filter input of the most recently selected tab. This is either the filter input within the "Branches" tab or the "Pull Requests" tab. The issue is that without proper ARIA
role
andaria-labelledby
attributes, screen readers do not announce any context regarding the parent elements of the input currently in focus. This PR fixes that by passingrole
andlabelledBy
properties from the branch dropdown down to the childFilterList
-ish components.This could have been solved in other ways by adding parent
div
elements inside of theBranchesContainer
component, that contained the correctrole="tabpanel"
andaria-labelledby
attributes. However, I think there is a benefit to the commonly usedFilterList
andSectionFilterList
components being able to have different ARIA attributes depending on the parent components usage of the properties.Screenshots
Release notes
Notes: [New] Improve branch dropdown tabs screen reader support