Git Product home page Git Product logo

Comments (4)

dylans avatar dylans commented on May 25, 2024 1

Thanks @user178392143 for verifying. I'll take a look and see if I have any ideas, but I'm mildly pessimistic as this is often an area where fixing one thing breaks three other things.

from slate.

dylans avatar dylans commented on May 25, 2024

The code in question hasn't changed in 3 years, but was added to work around https://issues.chromium.org/issues/40197599.

It's possible that Chrome recently changed behavior here (as they did break us in an interesting way in Chrome 112 or so).

You'll see at the bottom of the Chrome issue is the mention of

// Put this at the start and end of an inline component to work around this Chromium bug:
// https://bugs.chromium.org/p/chromium/issues/detail?id=1249405
const InlineChromiumBugfix = () => (
<span
contentEditable={false}
className={css`
font-size: 0;
`}
>
${String.fromCodePoint(160) /* Non-breaking space */}
</span>
)
.

What I would suggest:

  • Try the test case in https://issues.chromium.org/issues/40197599 , is this still a bug in Chrome?
  • If not, then we can remove the workaround, but need to determine the Chrome version when this behavior changed.
  • If still a bug, then I suggest trying to use the workaround suggested.

from slate.

user178392143 avatar user178392143 commented on May 25, 2024

Thanks! As far as I can tell, the Chromium bug still reproduces in Chrome (you can't manage to type at the beginning of the <code> node.)

I gave the inline workaround a try, but it didn't change the results. One thing to note is that the onInput issue occurs equally with inline or block nodes. In my minimal example, it's a block node (a <div>) that we're editing, and with my actual application, it's an inline. With the workaround I saw the same results in both: no onInput fired.

Here's the minimal example, which shows the bug within a <div>:

slate-noinput-div-block-element-with-workaround.mp4

from slate.

user178392143 avatar user178392143 commented on May 25, 2024

I've come up with a workaround for this. I can't vouch for its total reliability, but you can listen to onDOMBeforeInput and simply save the InputEvent it gives you for later processing, such as in onValueChange. This does mean you have to make your changes to the document after Slate has processed the input, which is probably the better course anyways. This has gotten me unblocked for the time being.

from slate.

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.