react-complex-tree icon indicating copy to clipboard operation
react-complex-tree copied to clipboard

Expand tree element without selecting it

Open andreash opened this issue 1 year ago • 1 comments
trafficstars

** I am trying to use react-complex-tree in controlled environment and I'd like to expand elements by clicking on the arrow without selecting the element at the same time. That doesn't seem to be configurable yet - a click on the arrow alway causes the onSelect event w/o providing the source of the event. Am I am missing something? If not, it would be great to have this feature.

Also, I forked the component to create a respective pull request but npm install fails with errors:

` npm WARN ERESOLVE overriding peer dependency

npm WARN ERESOLVE overriding peer dependency npm WARN ERESOLVE overriding peer dependency npm WARN ERESOLVE overriding peer dependency npm WARN ERESOLVE overriding peer dependency npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: [email protected] npm ERR! Found: [email protected] npm ERR! node_modules/react npm ERR! react@"^18.2.0" from [email protected] npm ERR! packages/docs npm ERR! [email protected] npm ERR! node_modules/docs npm ERR! workspace packages\docs from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@"^16.8.4 || ^17.0.0" from @docusaurus/[email protected] npm ERR! node_modules/@docusaurus/core npm ERR! @docusaurus/core@"2.2.0" from [email protected] npm ERR! packages/docs npm ERR! [email protected] npm ERR! node_modules/docs npm ERR! workspace packages\docs from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution.`

andreash avatar Dec 22 '23 09:12 andreash

If you don't want clicks on the arrow to change the selection state, you should be able to just overwrite the click handler of the arrow renderer:

renderItemArrow={ ({item, context}) => (
    <div
      {...context.arrowProps}
      onClick={item.isFolder ? context.toggleExpandedState : undefined}
    >
// ...

If you are trying to check out RCT locally and get it running, maybe try running it with yarn instead of npm, there are some yarn workspace specific setup dependencies in there and it might not work with npm.

lukasbach avatar Jan 18 '24 20:01 lukasbach