-
-
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
[DialogTitle] Documentation default variant different from default rendered #16569
Comments
@dayander Do you mean that we should change the description from default h2 to h6?
|
@oliviertassinari I think the default should be an h2 and match the documentation. Rendering as an h2 is best practice for accessibility. |
Do you have resources on why h2? |
Does the actual header used matter? |
Google owns Youtube and has people contributing to the working group for WAI-ARIA. Bootstrap is not a source for accessibility. Each page should contain one h1 denoting the whole meaning of the page. The next consecutive order after an h1 is h2. When the dialog becomes an overlay over the current page and should still fall under the content scope of the h1 and the next heading level should be an h2. |
@dayander Is this detailed somewhere? What's the impact? I would love to learn more about it.
Agree, it's not a source of truth. cc @eps1lon |
Hey, I was just chatting with @dayander a little bit about this and thought I could chime in with a few more resources to look at. The higher the ranking of the header, the less important it is on the page. A heading element should never exceed h6. Although theoretically you can go higher, and some screen readers may support it, the results can be unpredictable with other browser/screen reader combinations. [1] If the dialog header begins at h6, this can cause issues for screen readers if any other headers need to be added to the same dialog, as they would have to be an h7 or higher. [2] Another resource for this information can be found here: https://www.w3.org/WAI/tutorials/page-structure/headings/ 1: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/heading_role#Accessibility_concerns |
@Auchindoun Thanks, that sounds good to me. The change could be: diff --git a/docs/src/pages/components/modal/modal.md b/docs/src/pages/components/modal/modal.md
index 4299aa417..bf1c98774 100644
--- a/docs/src/pages/components/modal/modal.md
+++ b/docs/src/pages/components/modal/modal.md
@@ -88,9 +88,9 @@ Additionally, you may give a description of your modal with the `aria-describedb
aria-labelledby="simple-modal-title"
aria-describedby="simple-modal-description"
>
- <h6 id="modal-title">
+ <h2 id="modal-title">
My Title
- </h6>
+ </h2>
<p id="simple-modal-description">
My Description
</p>
diff --git a/packages/material-ui/src/DialogTitle/DialogTitle.js b/packages/material-ui/src/DialogTitle/DialogTitle.js
index f3cc523ce..e877b67b4 100644
--- a/packages/material-ui/src/DialogTitle/DialogTitle.js
+++ b/packages/material-ui/src/DialogTitle/DialogTitle.js
@@ -18,7 +18,7 @@ const DialogTitle = React.forwardRef(function DialogTitle(props, ref) {
return (
<div className={clsx(classes.root, className)} ref={ref} {...other}>
- {disableTypography ? children : <Typography variant="h6">{children}</Typography>}
+ {disableTypography ? children : <Typography component="h2" variant="h6">{children}</Typography>}
</div>
);
}); |
That sounds great. Thank you. I can make the changes and open a PR. |
Why is the h2 component given a class that renders it with h6 typography? |
@shiraze I don't understand. What do you mean? |
@oliviertassinari , sorry I just re-read what I said and it's not clear! The inner component is an |
@shiraze Thanks for the details. Yes, it's the expected behavior. Does https://material-ui.com/components/typography/#changing-the-semantic-element make it clearer? |
what's the cleanest way to override this h6 variant and use h2 instead, from the global overrides object? thanks |
@ghan Upgrade to v4 latest or target DialogTitle with https://material-ui.com/customization/globals/#default-props. |
Hi Oliver, thanks for responding. My question was a little vague, I apologize. I'm on v4.5 and want to have First disable the nested h2 element: props: {
MuiDialogTitle: {
disableTypography: true
}
} Then apply h2 styles to the DialogTitle component via overrides: overrides: {
MuiDialogTitle: {
root: {
fontFamily: headerFont,
fontSize: headerSize,
fontWeight: headerWeight,
lineHeight: headerLineheight
}
}
} I hope that demonstrates a little better why this feels sub-optimal to me. Let me know if you guys do something smarter, thanks! |
@ghan I'm sorry, It still unclear what's your objective, I would suggest to try StackOverflow. |
Hi @oliviertassinari, regarding @ghan 's use case. I actually came across the very exact issue. Although the DialogTitle allows us to customize the Typography component used within DialogType through If we wanted to have all DialogTitles rendering H3's, we would have to A possible solution might be to add a prop to DialogTitle called 'variant' which maps to
.... I came across this issue myself. I thought it was possible through some sort of api like
But that's not the case! :D For now I have to disableTypography in all our DialogTitles because ours requires to use the actual H2 font style. I can try to clarify it again if needed! |
Yes, I am also running into this issue. @KyruCabading proposed solution is exactly what I would have expected this component to support from the get-go. This would be a very useful update! |
In the documentation the default component rendered for DialogTilte is an h2 but an h6 is the default rendered element.
Expected Behavior 🤔
Based on documentation the default element rendered for DialogTitle is an h2 element.
![Screen Shot 2019-07-11 at 9 21 14 AM](https://user-images.githubusercontent.com/29063970/61061685-51a10200-a3c2-11e9-8ca6-4afea7c84c74.png)
Current Behavior 😯
The default element rendered is an h6
Steps to Reproduce 🕹
Link:
Context 🔦
To make our application more accessible, while also making it easier for people to contribute without a large knowledge base of accessibility.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: