bumbeishvili / org-chart

Highly customizable org chart. Integrations available for Angular, React, Vue
https://stackblitz.com/edit/web-platform-o5t1ha
MIT License
928 stars 330 forks source link

I want to get the background click be working on clicking of the chart container which is not happening #358

Open riyasat-ali opened 9 months ago

riyasat-ali commented 9 months ago

I want to get the background click work on clicking the chart container which is not happening, there might be some event.stopPropagation being applied and I want to override that. How can I do that?

bumbeishvili commented 9 months ago

Can you post an example of your trial?

You can override this one

https://stackblitz.com/edit/js-mfzkbs?file=index.html

tbrcanaplan commented 9 months ago

I happen to know what the issue is and i've updated the example. Click events propagate ok but mouseDown events don't. This issue might hold the answer:

Moving elements to the front by re-appending them to the DOM may prevent the browser from interpreting a sequence of mouse events (mousedown, mouseup) as a click gesture and dispatching a subsequent click event. Typically a mousedown and mouseup is only considered a click gesture if both events are received by the same element, and for whatever reason, the mouseup is considered a different element if you re-appended it to the DOM during the gesture. That’s the native browser behavior, and D3 is not a compatibility layer: it’s merely provides a facility for listening to the browser’s native events.