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

OnClick event in custom node element randomly stops working #458

Open
Liu233w opened this issue Apr 17, 2023 · 2 comments
Open

OnClick event in custom node element randomly stops working #458

Liu233w opened this issue Apr 17, 2023 · 2 comments

Comments

@Liu233w
Copy link

Liu233w commented Apr 17, 2023

Are you reporting a bug, or opening a feature request?

A bug

What is the actual behavior/output?

Please check this sandbox: https://codesandbox.io/s/onclick-event-not-triggered-qbw4dr?file=/src/App.js
If you click multiple elements one after another (e.g. click root node, then click first child, then click root node, ..., repeat multiple times), there is a chance that the onClick event not triggered when you click a node.

What version of react-d3-tree are you using?

3.5.2

@Liu233w
Copy link
Author

Liu233w commented Apr 20, 2023

After experimenting on the source code, I found that it was caused by bindZoomListener, and the problem is gone if if (!zoomable) return; is added before the svg.call. Probably because clicking event is somehow conflicted with the d3-zoom.

@jp1357
Copy link

jp1357 commented Jun 9, 2023

I had the exact same problem. And it is indeed in the zoomListener. But the reason I found out is that it is simply too sensitive.
So as soon as you click your mouse you might slightly move and then it is not seen as click but as drag or zoom movement.
The solution for me was setting the clickDistance to a number higher than 0 - I placed at 10 the same as with the touchDistance

But this react-d3-tree has not yet forwarded the d3-zoom clickDistance property, whence I made a Pull Request for it
#466

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

2 participants