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

Double click bug on foreignObject #267

Closed
shayantabrizi opened this issue Oct 27, 2020 · 4 comments
Closed

Double click bug on foreignObject #267

shayantabrizi opened this issue Oct 27, 2020 · 4 comments

Comments

@shayantabrizi
Copy link

I encounter a problem in double clicking foreignObjects. In this code, when we double click in the circle , in the console both 'click' and 'dblclick' logs appear. But when we double click the foreign object (H), only the 'click' log appears. If we comment either line 35 or line 40, dblclick also works for the foreign object.

@Fil Fil transferred this issue from d3/d3 Oct 27, 2020
@mbostock
Copy link
Member

This sounds like a browser quirk and not a D3 bug.

@shayantabrizi
Copy link
Author

I have tried it on Firefox, Chrome, and Edge. All of them had the same problem. You mean that d3 works correctly and all of them work incorrectly?

@mbostock
Copy link
Member

D3 doesn’t intercept event listeners or define its own event lifecycle or anything like that, so if an event listener is behaving weirdly when you use D3 to register an event listener, it’ll behave weirdly in the same way as if you use the web standard API directly (e.g., element.addEventListener). Hence this is either a browser bug or the expected behavior of web standards, but unlikely to be an issue with D3 because of how D3 works.

You can read the source of selection.on here:

https://github.com/d3/d3-selection/blob/master/src/selection/on.js

@shayantabrizi
Copy link
Author

The problem may be related to how d3 renders the objects, not only how events are handled. If line 40 is commented, it seems to work correctly. There may be a difference in how d3 handles foreignObjects and ordinary objects.

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