React Flow doesn't work in Shadow DOM
See original GitHub issueDescribe the Bug
I need to use React Flow inside Shadow DOM, but I ran into several errors:
- Uncaught TypeError: Failed to execute ‘getComputedStyle’ on ‘Window’: parameter 1 is not of type ‘Element’.
I made a small local fix in node_modules to check new behavior:
replaced this document.querySelector('.react-flow__viewport')
whith this document.querySelector('#shadow').shadowRoot.querySelector('.react-flow__viewport')
- '#shadow'
is my element with Shadow DOM.
And I got the following bug
- There are broken view for nodes and edges
Your Example Website or App
https://github.com/KislyakovDS/react-flow-with-shadow-dom
Steps to Reproduce the Bug or Issue
- Go to https://react-flow-with-shadow-dom.vercel.app/
- Open browser console to see error
Expected behavior
As a user, I expected behavior from this example https://reactflow.dev/docs/examples/overview/
Screenshots or Videos
No response
Platform
- OS: [Windows]
- Browser: [Chrome]
- Version: [103.0.5060.114]
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Scroll doesn't work in Shadow DOM #4512 - GitHub
I have a project that is entirely written in Shadow DOM. To my surprise, react-select doesn't work properly in shadow root. Styles don't...
Read more >Click event not firing when React Component in a Shadow DOM
As it turns out the Shadow DOM retargets click events and encapsulates the events in the shadow. React does not like this because...
Read more >Troubleshooting Guide - React Flow
Doesn't work : import ReactFlow from 'reactflow'; import 'reactflow/dist/style.css'; import MyCustomNode from './MyCustomNode'; const nodes = [
Read more >Virtual DOM and Internals - React
The Shadow DOM is a browser technology designed primarily for scoping variables and CSS in web components. The virtual DOM is a concept...
Read more >Shadow DOM - Material UI - MUI
The shadow DOM lets you encapsulate parts of an app to keep them separate from global styles that target the regular DOM tree....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for quick fix))
Alright. Thanks again! Fixed in v10.3.12