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

fix(Tabs): Allow rendering Tabs and TabPanels conditionally again #17859

Merged

Conversation

remolueoend
Copy link
Contributor

This change allows users to conditionally render children of TabPanels again: If children are not filtered for nullish/falsy values before cloning them, React.cloneElement will fail with: Error: React.cloneElement(...): The argument must be a React element, but you passed null..

This regression has been introduced with commit: f4066328a01bd9431f16ccc0c8b646f1f6d8a26e, Tabs.tsx:L1257

Changelog

Changed

  • filter children of TabPanels for nullish or falsy values using isElement before cloning them.

Testing / Reviewing

@remolueoend remolueoend requested a review from a team as a code owner October 23, 2024 17:20
Copy link

netlify bot commented Oct 23, 2024

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit d3c961e
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/67193513764bb60008d35e79
😎 Deploy Preview https://deploy-preview-17859--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 23, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit d3c961e
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/671935136b1ce30007cc542c
😎 Deploy Preview https://deploy-preview-17859--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 23, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d3c961e
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/671935133bce88000841c205
😎 Deploy Preview https://deploy-preview-17859--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.15%. Comparing base (c6ebc2d) to head (d3c961e).
Report is 41 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17859   +/-   ##
=======================================
  Coverage   80.14%   80.15%           
=======================================
  Files         406      406           
  Lines       14030    14031    +1     
  Branches     4343     4345    +2     
=======================================
+ Hits        11245    11246    +1     
  Misses       2619     2619           
  Partials      166      166           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This change allows users again to conditionally render children of TabPanels:
If children are not filtered for nullish/falsy values before cloning them,
`React.cloneElement` will fail.

This regression has been introduced with commit:
f406632, Tabs.tsx:L1257
@remolueoend remolueoend force-pushed the fix/conditional-tab-panel branch from b7669fb to d3c961e Compare October 23, 2024 17:40
Copy link
Member

@ariellalgilmore ariellalgilmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kennylam kennylam added this pull request to the merge queue Oct 29, 2024
Merged via the queue into carbon-design-system:main with commit a24e338 Oct 29, 2024
39 of 40 checks passed
@remolueoend remolueoend deleted the fix/conditional-tab-panel branch October 29, 2024 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants