formio.js icon indicating copy to clipboard operation
formio.js copied to clipboard

Doesnt work with Shadow Dom elements.

Open sezerkorkmaz opened this issue 6 years ago • 12 comments

We use angular wrapper version of this library and using shadow dom for our components. Formio JS library doesnt work with Shadow Root elements. For example for dragging, formio use dragula library. All draggable elements has "drag-copy" class. So the javascript library can reach them via

document.getElementsByClassName('drag-copy')

but in the shadow root, it need reach via document.getElementsByTagName('parent-element')[0].shadowRoot.querySelectorAll('.drag-copy');

Is there any way to solve this issue?

sezerkorkmaz avatar Jul 05 '19 06:07 sezerkorkmaz

I'm not sure that change would work with people not using shadow dom elements so we can't make that change in our library. I'm not sure that we have a good grip on the issue as we don't typically use the shadow dom. We are definitely open to fixing this but need a solution that will work for everyone.

randallknutson avatar Jul 08 '19 15:07 randallknutson

I am also facing the same issue as trying to integrate it with webcomponents. Is there any plan to fix this?

Ankita-G-Mudgal avatar Sep 11 '20 10:09 Ankita-G-Mudgal

We don't currently have any plans to change this as it doesn't occur in any of the systems we are currently working with. We would be happy to accept a pull request that solves your use case.

randallknutson avatar Sep 11 '20 14:09 randallknutson

Is the problem in formio or in the dragula library?

olliejm avatar Nov 27 '20 16:11 olliejm

Closing this thread as it is stale. Please feel free to reopen if needed.

heather-formio avatar Oct 12 '22 12:10 heather-formio

fwiw, I'm finding the renderer does work inside a shadow DOM for simple components (I haven't tested anything else) so long as you use the html5 widget for "select" elements instead of choicesjs.

There is hope, weary traveller who finds this thread.

jfulfordebay avatar Aug 21 '23 23:08 jfulfordebay

Our Inline Embed works inside shadow dom. Try it out and inspect the Dom and you will see it is shadow dom, so we know it does work.

<script src="https://cdn.form.io/js/formio.embed.min.js?src=https://examples.form.io/example&libs=true"></script>

Here is the fiddle.

https://jsfiddle.net/travistidwell/uys26qpf/

travist avatar Aug 22 '23 01:08 travist

Has anyone tested with the builder?

StephenOTT avatar Apr 24 '24 17:04 StephenOTT

Looks to be an issue with dragula not properly supporting shadow dom. This (https://github.com/bevacqua/dragula/pull/470) PR (sadly never merged) looks to solve the issues, but its quite fiddly to jam into formio.

lukethacoder avatar Jul 07 '25 10:07 lukethacoder

We're happy to review again, @lukethacoder. Can you please describe the details of the use case you are after and the current versions of everything you're using? Once received, We'll take a look at the PR and see if anything has changed on our opinions regarding this thread.

heather-formio avatar Jul 07 '25 11:07 heather-formio

I'm attempting to load the Formio builder inside a Shadow DOM element. It seems to load fine, but the Drag and Drop does not work due to Dragula not having Shadow DOM support.

  • dragula: v3.7.3
  • formio: latest (5.0.0. - via https://cdn.form.io/js/formio.form.min.js)

Have yet to test the rendering side of things as I'm less concerned about that for my specific use case so far.

lukethacoder avatar Jul 07 '25 11:07 lukethacoder

Thanks @lukethacoder, I'm looking into the dragula library overall and seeing what we can do about this. Stay tuned.

heather-formio avatar Jul 07 '25 13:07 heather-formio