-
-
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
[Tabs] wrapping tabs in custom function breaks onChange #13893
Comments
We should add this limitation to the docs. It's the same issue that's causing troubles with wrapped Tooltips around Tabs. Basically a A workaround for now is to use a render function instead of a component. |
It's simpler than that: they can just forward the properties, it's a 1-2 lines change.
We try to cover this part in https://material-ui.com/guides/composition/. I doubt we can do more about it, any idea? Hum, maybe we could enforce the usage of Related to #12921. |
Oh, I just need to compose the props? Sorry guys, never seen that page of the docs :/ |
@el1f Yes, you can solve the problem like this: - const TabItem = ({ label }) => (
+ const TabItem = ({ label, ...props }) => (
<Tab
classes={{
root: "Tabs-layout__tabs__item",
labelContainer: "Tabs-layout__tabs__label"
}}
label={<TabLabel>{label}</TabLabel>}
disableRipple
+ {...props}
/>
); |
Expected Behavior 🤔
When using a
Tabs
components with a custom child which renders aTab
component as it's only child it should work as if I'm writing the tabs as direct children of theTabs
component.Current Behavior 😯
onChange
andactive
don't seem to propagate to the tabs rendered by the custom component. Is this the intended behaviour? Can I pass the props to my custom component somehow?Steps to Reproduce 🕹
Link: https://codesandbox.io/s/l2762q1kwl
TabItem
with aTab
and give it thetab
prop instead of thelabel
propContext 🔦
I'm trying to get my Tabs in wrappers to avoid repetition to the best of my ability and I'm trying to understand why this is the case with tabs
Your Environment 🌎
The text was updated successfully, but these errors were encountered: