-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[material-ui][docs] Add aria-current for nav tabs demo #39594
Conversation
Netlify deploy previewhttps://deploy-preview-39594--material-ui.netlify.app/ Bundle size report |
ARIA docs explicitly state that the active tab should have the
|
I've updated the PR and add |
Why would we need both? Neither ARIA docs nor demos for the tab role mention the |
there was an open issue for that and I have trying to fix #32924 |
Sorry, I should have explained this better. I haven't noticed at first that you're fixing #32924. |
thank you so much. Just I have another question to clarify solution.
|
4a76404
to
ff1897c
Compare
As I was checked, if
@michaldudak, could you please check the PR again? |
@@ -34,6 +35,7 @@ function LinkTab(props: LinkTabProps) { | |||
event.preventDefault(); | |||
} | |||
}} | |||
aria-current={props.selected && "page"} |
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.
aria-current={props.selected && "page"} | |
aria-current={props.selected ? "page" : undefined} |
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.
Also, please add aria-selected={undefined}
at the end to override the default behavior of the Tab.
<Tab
component="a"
onClick={(event) => {
// Routing libraries handle this, you can remove the onClick handle when using them.
if (samePageLinkNavigation(event)) {
event.preventDefault();
}
}}
aria-current={props.selected && "page"}
{...props}
aria-selected={undefined}
/>
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.
for the first issue, as I was checked, based on w3 document the default value of aria-current
is false.
If the attribute is not present or its value is an empty string or undefined, the default value of false applies and the aria-current state MUST NOT be exposed by user agents or assistive technologies.
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.
and for the second issue, we still need aria-selected
tag, because aria-selected
and aria-current
represents different concepts and meanings here.
based on w3 document:
In some use cases for widgets that support aria-selected, current and selected can have different meanings and can both be used within the same set of elements.
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.
Thanks for the info!
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.
Based on #32924 (comment), the Tabs should have role="navigation"
as well.
When you update the code, please run yarn docs:typescript:formatted
.
@@ -27,11 +28,17 @@ function LinkTab(props) { | |||
event.preventDefault(); | |||
} | |||
}} | |||
aria-current={props.selected && 'page'} | |||
role="navigation" |
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.
role="navigation" |
role="navigation"
should be at Tabs element below, not Tab.
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.
Fixed.
@siriwatknp @michaldudak, current PR is ready to review again. could you please check it if you have time? |
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.
👍 Thanks for the improvements!
Co-authored-by: siriwatknp <siriwatkunaporn@gmail.com> Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
This PR changed
aria-selected
toaria-current
inTab
component.From the MDN docs:
the aria-selected docs define the following.
Closes #32924
https://deploy-preview-39594--material-ui.netlify.app/material-ui/react-tabs/#nav-tabs