ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.33k stars 3.22k forks source link

Server side rendering results in spellCheck, autoCorrect, and autoCapitalize mismatch #4318

Open daniel-keller opened 3 years ago

daniel-keller commented 3 years ago

Description Using SlateJS in server side rendering (in this case through NextJS) results in mismatching spellCheck, autoCorrect, and autoCapitalize between server and client. The result is these features fail to work in slate editors that are rendered server side. SlateJS's Editable component sets these properties based on HAS_BEFORE_INPUT_SUPPORT which (I assume) isn't available server side.

Recording

Screen Shot 2021-06-03 at 11 04 24 AM

Sandbox https://codesandbox.io/s/github/daniel-keller/nextjs-slatejs-spellcheck-bug

Steps To reproduce the behavior:

  1. Open the sandbox https://codesandbox.io/s/github/daniel-keller/nextjs-slatejs-spellcheck-bug
  2. The sandbox server side renders the Editable component with spellCheck, autoCorrecct, or autoCapitalize set. A similar error occurs when you remove any of these properties (properties on server absent on client)
  3. See error in Console

Expectation spellcheck, autocorrect, and autocapitalize have worked in server side rendering in previous versions of SlateJS (0.58.0).

Environment

cloudre01 commented 2 years ago

facing the same issue here. Using the version 0.58.x solved this issue when using on Nextjs.

matthewkeil commented 2 years ago

I solved this for next@12.0.2 and slate@0.70.0 using.

<Editable
  className={styles.editable}
  spellCheck={false}
  autoCorrect="false"
  autoCapitalize="false"
/>
matthewkeil commented 2 years ago

added PR https://github.com/ianstormtaylor/slate/pull/4682