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

EditMode not working properly in ShadowDOM #52

Open
manuelroth opened this issue Jan 28, 2019 · 5 comments
Open

EditMode not working properly in ShadowDOM #52

manuelroth opened this issue Jan 28, 2019 · 5 comments

Comments

@manuelroth
Copy link
Contributor

manuelroth commented Jan 28, 2019

Hi @susielu ,
Thank you for this great d3 plugin. Really love working with it. I encountered a problem when using d3-annotation inside a shadowDOM:

Problem:

My svg element lives inside a shadowDOM. If the element is in editMode it is not possible to drag the annotation handles. I have created a codepen to reproduce the problem -> https://codepen.io/anon/pen/GzqvbY?editors=1010

Try to drag the annotation handles and check the console for the error message (Cannot read property 'ownerSVGElement' of null).

Possible solution

I did some debugging and found out that the drag handler is registered on all elements passing this selector g.annotations (see code here):

drag().container(select("g.annotations").node())

This doesn't play nicely with shadowDOM, because the svg element inside the shadowDOM is not visible from outside. A possible solution could be to make the selection relative to the annotation-group:

drag().container(group.selectAll("g.annotations").node())

I wanted to create a PR but failed to implement a working solution. Do you have an idea how we could fix this?

Kind regards,
Manuel

@susielu
Copy link
Owner

susielu commented Feb 5, 2019

Hey Manuel, thanks for posting this. I haven't worked with the shadowDOM before. Thanks for making a codepen example. I'll take a look.

@manuelroth
Copy link
Contributor Author

manuelroth commented Mar 24, 2019

Hi @susielu, just wanted to let you know that I used your library to cover communal elections in the canton of zurich (switzerland). Thank you so much, it let us build this in a very short time -> https://www.nzz.ch/zuerich/regierungsrat-und-kantonsrat-zuerich-die-resultate-der-wahlen-ld.1465859?h

Bildschirmfoto 2019-03-24 um 14 55 47

Kind regards,
Manuel

@susielu
Copy link
Owner

susielu commented Mar 24, 2019

Thanks Manuel, still haven't put aside time to look at the shadow dom example, were you able to get your use case to work around it?

@susielu
Copy link
Owner

susielu commented Mar 24, 2019

Really great to see the example, thanks for sharing!

@manuelroth
Copy link
Contributor Author

Yes, I was able to work around it. It would still be helpful for future use of the library though. I think its always cool to share back some implementation examples to an open source project.

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