Skip to content
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/Tab component enhancements #3397

Closed
joshblack opened this issue Jul 15, 2019 · 7 comments
Closed

Tabs/Tab component enhancements #3397

joshblack opened this issue Jul 15, 2019 · 7 comments
Labels
package: react carbon-components-react status: inactive Will close if there's no further activity within a given time type: enhancement 💡

Comments

@joshblack
Copy link
Contributor

We should schedule some time to refactor/update the tab components with the following constraints in mind:

  • Should support keyboard navigation, related to: feat(tabs): support home/end keyboard navigation #3258
  • Could be updated to hooks to help address getDerivedStateFromProps
  • Should keep in mind that we're using it in MDX and test with null and wrapped children accordingly
    • Specifically, renderContent as a defaultProp may not be properly hoisted and is causing issues within MDX
@vpicone
Copy link
Contributor

vpicone commented Jul 15, 2019

At some point between 10.2 and 10.3 a regression caused the tabs content to not properly render, the result being an undefined element. In my opinion, special care should be used around the React helpers. They'll be required here to add an index to the tabs.

However, I think the top level helpers should likely be avoided if using JSX is possible, as mixing cloneElement, with JSX, with mapping over children can make the component harder to reason about.

In summary,

This code worked with 7.2

export const Tabs = props => (
  <CarbonTabs
    className={tabContainer}
    tabContentClassName={tabContents}
    {...props}
  />
);

This code is required for 7.3+

export const Tabs = props => (
  <CarbonTabs className={tabContainer} tabContentClassName={tabContents}>
    {React.Children.map(props.children, child =>
      React.cloneElement(child, {
        renderContent: TabContent,
      })
    )}
  </CarbonTabs>
);

@joshblack
Copy link
Contributor Author

@vpicone could you provide more info to help with isolating the issue? renderContent specifically seems to be caused by usage with MDX, as by default it is supplied under defaultProps on the Tab component.

@vpicone
Copy link
Contributor

vpicone commented Jul 15, 2019

@joshblack I'm not sure, only the props set in the cloneElement call are making it to the component. Seems like we could address this using the TabContent as a default in the Tabs component and not relying on default props of Tab? Seems like there's some discrepancy in when default props are loaded for create and clone element in react but I'm not sure if that has any relevancy.

@vpicone
Copy link
Contributor

vpicone commented Jul 15, 2019

All things equal (mdx/gatsby/other deps) Tabs worked in 7.2 but not 7.3+ so I don't think we can blame MDX here but I could be wrong.

@joshblack
Copy link
Contributor Author

joshblack commented Jul 15, 2019

@vpicone I'm not suggesting MDX is to blame, I'm requesting that we offer more details to help reproduce and fix the issue. This seems to be coming up when used alongside MDX, but if this is an issue outside of this scope then that's totally fine 👍 As long as there is a way for someone working on this to reproduce, identify, and fix the issue.

@stale
Copy link

stale bot commented Aug 14, 2019

We've marked this issue as stale because there hasn't been any activity for a couple of weeks. If there's no further activity on this issue in the next three days then we'll close it. You can keep the conversation going with just a short comment. Thanks for your contributions.

@stale stale bot added the status: inactive Will close if there's no further activity within a given time label Aug 14, 2019
@stale
Copy link

stale bot commented Aug 17, 2019

As there's been no activity since this issue was marked as stale, we are auto-closing it.

@stale stale bot closed this as completed Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: react carbon-components-react status: inactive Will close if there's no further activity within a given time type: enhancement 💡
Projects
None yet
Development

No branches or pull requests

2 participants