-
Notifications
You must be signed in to change notification settings - Fork 268
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
Node missing parent attribute (onNodeClick callback) in v2.x #349
Comments
… handlers (#349) BREAKING CHANGE: All top-level `onNode` handlers now pass `node: HierarchyPointNode<TreeNodeDatum>` as their first parameter. This change aligns `Node` handlers with those of `Link`, which already return `HierarchyPointNode<TreeNodeDatum>` for their `sourceNode` and `targetNode` parameters. Additionally, this addresses an unintended implicit regression when comparing node handlers to v1 (#349), such as restoring the `parent` node reference in the handlers' `node` parameter.
Hi @Joroze, Thanks for making me aware of this, this was an unintended regression during the huge This is one of those refactoring slip-ups where I ask myself how I could've missed this, also because the correct implementation - aligning the type of I'm almost done with a fix, but need to put some more due diligence into the release process, since this will need to ship as |
… handlers (#349) BREAKING CHANGE: All top-level `onNode` handlers now pass `node: HierarchyPointNode<TreeNodeDatum>` as their first parameter. This change aligns `Node` handlers with those of `Link`, which already return `HierarchyPointNode<TreeNodeDatum>` for their `sourceNode` and `targetNode` parameters. Additionally, this addresses an unintended implicit regression when comparing node handlers to v1 (#349), such as restoring the `parent` node reference in the handlers' `node` parameter.
Fixed in v3.0.0. While technically a breaking change due to the adjustment needed in the top-level API, this should be a relatively painless upgrade from v2. The linked release notes also contain a before/after comparison to hopefully make things easier 🤞 Thanks again for reporting this 👍 |
Hi @bkrem, no problem! How would you feel about the For example, in this CodeSandbox for custom event handlers, A possible solution is to update this line of code to pass react-d3-tree/src/Node/index.tsx Line 123 in f749d43
to return renderCustomNodeElement({ nodeDatum: this.props.hierarchyPointNode, toggleNode: this.handleNodeToggle });
EDIT: I created a pull request to demonstrate. This probably needs to be refactored. |
Are you reporting a bug, or opening a feature request?
Bug
What is the actual behavior/output?
In version 1.x, the node object that the onClick callback function has contains a "parent" attribute. onNodeClick seems to replace onClick in version 2.x, but the node passed into the callback no longer contains a "parent" attribute.
What is the behavior/output you expect?
onNodeClick should accept the selected node which contains a parent attribute pointing to its parent node (if exists)
Can you consistently reproduce the issue/create a reproduction case (e.g. on https://codesandbox.io)?
Yes
What version of react-d3-tree are you using?
2.x (any 2.x)
The text was updated successfully, but these errors were encountered: