-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tabs] Using fragments in Tabs child node breaks functionality #30153
Comments
The |
@michaldudak this is not working if I want to render some more things in the tab, like icon+text using the component property of Tab. It still makes it a single tab if I use a map to render the data in tabs. |
@michaldudak Can you please open this issue again? |
Please create a codesandbox showing the issue you're facing. |
On stack overflow, I saw to use the component property to add custom text to tabs. But it is not working. |
@Nyctophiliac1918 I found that forwarding the ref if you want to use the component property works here's the sandbox. |
Thank you so much @jacobsickels! |
Hi @jacobsickels, I have a slightly similar problem, in this case I would like to create a custom element that returns the tab to remove some of the boilerplate, but I cannot use the custom element, it only works if I call it as a function: // This works
{CustomTab2()}
// This does not
<CustomTab3 /> https://codesandbox.io/s/basictabs-material-demo-forked-ym2g53?file=/demo.tsx Do I need to pass the ref in some way? |
@manulera I think what you want works if you spread in the props for your CustomTab3 https://codesandbox.io/s/basictabs-material-demo-forked-wg97pd?file=/demo.tsx |
Well that was fast! Thank you so much, it works! |
Duplicates
Latest version
Current behavior 馃槸
Functional component child nodes of
Tabs
wrapped in fragments break functionality. For example, if I have a custom functional component<DynamicTabs />
that returns multipleTab
elements with a fragment root and use<DynamicTabs />
as a child ofTabs
, it seems to break the functionality. If I don't use fragments here then I get a TS error for returning an array of elements, and replacing the fragment root with adiv
orspan
also does not work:Expected behavior 馃
The expected behavior is that functional components that return an element with a fragment root don't break
Tabs
functionality when transcluded into<Tabs>
.For a workaround, I could just avoid using a custom functional component and instead do something inline, but I would ideally like to avoid the code below:
Steps to reproduce 馃暪
codesandbox: https://codesandbox.io/s/basictabs-material-demo-forked-cbze4?file=/demo.tsx:1310-1475
Steps:
Context 馃敠
Using fragments should not break the Tab functionality. Using functional components wrapped in fragments works for TabPanel, but not for children of Tabs. This forces me to use the inline method which hurts readability and consistency. This may or may not be related to: #27947
Your environment 馃寧
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: