Skip to content

fix(TreeView): treeview not passing props to treenode children #19417

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

Conversation

Gopi-Agasthia-S-005CIU744
Copy link
Contributor

@Gopi-Agasthia-S-005CIU744 Gopi-Agasthia-S-005CIU744 commented May 19, 2025

Closes #19136

Addressed the issue where TreeView doesn't pass props to TreeNode if TreeNode is wrapped by a component

Changelog

Changed

  • Refactored the way TreeView and TreeNode passes the prop to its children to recursively check for TreeNode Component in children

Testing / Reviewing

  • In the TreeView story wrap the TreeNode with a div to check if props are passed correctly

PR Checklist

As the author of this PR, before marking ready for review, confirm you:

  • Reviewed every line of the diff
  • Updated documentation and storybook examples
  • Wrote passing tests that cover this change
  • Addressed any impact on accessibility (a11y)
  • Tested for cross-browser consistency
  • Validated that this code is ready for review and status checks should pass

More details can be found in the pull request guide

Copy link
Contributor

github-actions bot commented May 19, 2025

All contributors have signed the DCO.
Posted by the DCO Assistant Lite bot.

Copy link

netlify bot commented May 19, 2025

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

Name Link
🔨 Latest commit dfea6b7
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/682c1fe37d5da70008f3fc33
😎 Deploy Preview https://deploy-preview-19417--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 project configuration.

Copy link

netlify bot commented May 19, 2025

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit dfea6b7
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/682c1fe319f3ea00075ef7a0
😎 Deploy Preview https://deploy-preview-19417--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 project configuration.

@heloiselui heloiselui requested a review from tay1orjones May 19, 2025 11:14
Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.88%. Comparing base (b8c7071) to head (dfea6b7).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #19417      +/-   ##
==========================================
+ Coverage   84.87%   84.88%   +0.01%     
==========================================
  Files         372      372              
  Lines       14431    14444      +13     
  Branches     4748     4751       +3     
==========================================
+ Hits        12248    12261      +13     
  Misses       2037     2037              
  Partials      146      146              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Gopi-Agasthia-S-005CIU744
Copy link
Contributor Author

I have read the DCO document and I hereby sign the DCO.

Copy link
Contributor

@heloiselui heloiselui left a comment

Choose a reason for hiding this comment

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

Thank you so much for doing this! The code looks great!

Just one thing, can you add some tests for lines [188–189] and [211–212], as they are not currently covered by our tests.

Also, a small suggestion for clarity (totally optional, both are functionally equivalent):
I would replace in TreeNode.tsx file, lines [182–184]:

tabIndex: (!(node as ReactElement).props.disabled && -1) || null,

you could use:

tabIndex: node.props.disabled ? null : -1,

@tay1orjones
Copy link
Member

Please do not remove checklist items from the pr template. If some do not apply, just ~strike out the text with tildes~

@Gopi-Agasthia-S-005CIU744
Copy link
Contributor Author

Gopi-Agasthia-S-005CIU744 commented May 19, 2025

Thank you so much for doing this! The code looks great!

Just one thing, can you add some tests for lines [188–189] and [211–212], as they are not currently covered by our tests.

Also, a small suggestion for clarity (totally optional, both are functionally equivalent): I would replace in TreeNode.tsx file, lines [182–184]:

tabIndex: (!(node as ReactElement).props.disabled && -1) || null,

you could use:

tabIndex: node.props.disabled ? null : -1,

  • Added test case wherein a Treenode is wrapped in another component

  • Refactored the TreeNode.tsx file -> used tabIndex: node.props.disabled ? null : -1 instead of tabIndex: (!(node as ReactElement).props.disabled && -1) || null

Copy link
Contributor

@heloiselui heloiselui left a comment

Choose a reason for hiding this comment

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

LGTM!

@tay1orjones tay1orjones added this pull request to the merge queue May 20, 2025
Merged via the queue into carbon-design-system:main with commit 9b3655f May 20, 2025
37 checks passed
@carbon-automation
Copy link
Contributor

Hey there! v11.83.0 was just released that references this issue/PR.

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.

[Bug]: TreeView not passing props to TreeNode children when in controlled state
3 participants