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

Tree not centering when using renderCustomNodeElement prop #494

Open
nadavq opened this issue Feb 9, 2024 · 0 comments
Open

Tree not centering when using renderCustomNodeElement prop #494

nadavq opened this issue Feb 9, 2024 · 0 comments

Comments

@nadavq
Copy link

nadavq commented Feb 9, 2024

I am using the Tree element as follows (the dimensions object fixed values are only for testing):


 <Tree
                    data={treeData}
                    orientation="vertical"
                    enableLegacyTransitions={true}
                    dimensions={{width: 1056, height: 489}}
                    renderCustomNodeElement={(rd3tProps) => {
                        return <SingleTreeNode {...rd3tProps} />
                        }
                    }
                    rootNodeClassName={classes.treeNode}
                    branchNodeClassName={[classes.node__branch, classes.treeNode].join(' ')}
                    leafNodeClassName={classes.treeNode}
                    pathClassFunc={() => classes.customLink}
                    {...nodeProps}
                />

My SingleTreeNode component is as follows:

<g onClick={onClickNode}>
           <rect r={15}></rect>
           <animate attributeName="opacity"
                    values="0;1" dur="300ms"/>
           <foreignObject {...foreignObjectProps} style={{overflow: 'visible'}}>
               <div ref={ref} className={['node-inner-container', classes.glass, classes.nodeInnerContainer].join(' ')} id={id} onMouseEnter={onHoverNode}
                    onMouseLeave={onUnHoverNode}>
                   <h3 style={{textAlign: "center"}}>{nodeDatum.name}</h3>
                   <p>{nodeDatum.attributes && nodeDatum.attributes.description ? nodeDatum.attributes.description : ""}</p>
               </div>
           </foreignObject>
       </g>

Unfortunately on clicking a node it doesn't center the tree, but when I remove the 'renderCustomNodeElement' prop it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant