Bug: Binding to webcomponent shadow root fails
See original GitHub issueI’m working on converting lexical into an es6 module + webcomponent. I’ve been able to successfully bundle an es6 module (using webpack). Using it as a top-level component in the HTML document root works, but including it as a webcomponent doesn’t.
Lexical version: 0.25
Steps To Reproduce
- import a bundled
lexical.bundle.min.js
file - bind Lexical to an editor in the root DOM (ie. document.getElementById(“editor”)), and observe that it works
- bind Lexical to an editor in the shadow DOM (this.shadowRoot.querySelector(“#editor”), and observe that it doesn’t work.
- The shadow dom’s editor does receive attributes for
data-lexical-editor=true
among others - The shadow dom does not receive key inputs
Link to code example:
https://user-images.githubusercontent.com/9470098/167487085-048ee412-6564-47cc-91f4-285bd9342a58.mov
https://github.com/yuzuquats/lexical-web-component
Any help would be appreciated! I’m fairly new to npm so if there’s anything obvious I’m missing I’d love to learn!
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Selection APIs for Shadow DOM #79 - GitHub
Title: [Shadow]: Find a way for selection to work across shadow DOM subtrees ... Bug: Binding to webcomponent shadow root fails facebook/lexical#2119. Open....
Read more >806506 - Implement web components ShadowRoot interface.
The range is disconnected and the selection ends up getting cleared, but the selection still remains painted. You can reproduce this now by...
Read more >Click event not firing when React Component in a Shadow DOM
I added a 'retargetEvents' method which binds all the possible event types to the container. It then will dispatch the correct React event...
Read more >Shadow DOM v1 - Self-Contained Web Components
Subtle bugs creep up, CSS specificity becomes a huge issue ( !important all ... Shadow DOM is one of the three Web Component...
Read more >348991 - DevTools cannot edit content in shadow DOM
Steps to reproduce the problem: 1. Visit http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom-301. ... 3. Right-click the text two lines ...
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
FYI: seems like this might be a common problem and selection APIs across shadow DOM boundaries are being worked on
In the meantime, I’ve opted to work around webcomponents with a simple class shim. Feel free to close this out unless you think there are better ways to work around this!
Thanks for the comprehensive report and digging into the logic on this!