Giter Site home page Giter Site logo

Comments (2)

Wildhoney avatar Wildhoney commented on August 19, 2024 1

By stepping through the stack trace I can see that it's traversing up the DOM until it finds x.ownerDocument.body which it will never be able to do being under a shadow boundary.

Screenshot #1

You can see above what it's trying to do — Draft is essentially traversing upwards to find the first element is encounters that has an overflow of either auto or scroll:

Screenshot #2

You can fix with unknown consequences by applying the requested overflow on an element inside the shadow boundary, so it doesn't need to keep traversing until it finds the x.ownerDocument.body element:

<div style={{ overflow: 'scroll' }}>

See line #18 in the updated JSFiddle and notice how the focus now works without throwing errors.

Nevertheless, when you type in the div it throws more errors, and by stepping through the stack trace of that error you can see it's caused by the findAncestorOffsetKey method:

Screenshot #3

You can see that the method is expecting to stop traversing once it finds the doument.documentElement node, which again because you've nested it under a shadow boundary, it will never be able to do.

Conclusion? You could attempt to find workarounds, but I think the problem essentially lies in the way Draft is written. It's simply making too many assumptions that it's always able to access either document.documentElement or x.ownerDocument.body which because of the nature of shadow boundaries, that just isn't true.

from reactshadow.

michaelcox avatar michaelcox commented on August 19, 2024

Thanks a lot for the super detailed response @Wildhoney. I'm going to close out this ticket as there's obviously nothing that can be done in this library. But I'm going to use what you've taught me here to try to come up with a workaround myself. Or (ugh) see if I can get some changes into Draft to support this use case better.

from reactshadow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.