-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] Fix the Basic Tabs demo #42253
Conversation
To avoid validateDOMNesting warning, we can use span as a component of Typography instead of p (default component). A <p></p> tag can only contain inline elements. That means putting a <div></div> tag inside it should be improper, since the div tag is a block element. Improper nesting might cause glitches like rendering extra tags, which can affect your javascript and css. Signed-off-by: Matheus Eli <31008177+MatheusEli@users.noreply.github.com>
Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Signed-off-by: Matheus Eli <31008177+MatheusEli@users.noreply.github.com>
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.
@MatheusEli You're right that a div
shouldn't be inside a p
, but this demo doesn't include a div
child in the rendered Typography. If your app uses a div
child, you should add component="span"
. Adding it in this demo is unnecessary.
I agree @ZeeshanTamboli but i've seen a lot of people getting these warnings because you usually will put some tags and components inside tabs, maybe this will help them not getting that? like @qkeddy said in #21015 |
I understand your point after reading the comments in issue #21015. The issue is that users don't realize Typography renders a --- a/docs/data/material/components/tabs/BasicTabs.tsx
+++ b/docs/data/material/components/tabs/BasicTabs.tsx
@@ -1,7 +1,6 @@
import * as React from 'react';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';
-import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
interface TabPanelProps {
@@ -21,11 +20,7 @@ function CustomTabPanel(props: TabPanelProps) {
aria-labelledby={`simple-tab-${index}`}
{...other}
>
- {value === index && (
- <Box sx={{ p: 3 }}>
- <Typography>{children}</Typography>
- </Box>
- )}
+ {value === index && <Box sx={{ p: 3 }}>{children}</Box>}
</div>
);
} |
You're right, removing the Typography component from the demo is a better solution |
Signed-off-by: Matheus Eli <31008177+MatheusEli@users.noreply.github.com>
@MatheusEli, I noticed your branch is pointing to |
Sure! here it is: #42374 |
To avoid validateDOMNesting warning, we can use span as a component of Typography instead of p (default component).
A p tag can only contain inline elements. That means putting a div tag inside it should be improper, since the div tag is a block element. Improper nesting might cause glitches like rendering extra tags, which can affect your javascript and css.