Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The editor does not get updated when changing its value #4689

Closed
delijah opened this issue Nov 25, 2021 · 5 comments
Closed

The editor does not get updated when changing its value #4689

delijah opened this issue Nov 25, 2021 · 5 comments
Labels

Comments

@delijah
Copy link
Contributor

delijah commented Nov 25, 2021

Description
The editor does not get updated when changing its value to something else than what we get in the change handler of slate. In older versions of slate this worked.

Recording
Version 0.71.0 (broken):
nothing-happens
Version 0.66.0 (ok):
this-works

Sandbox
Version 0.71.0 (broken): https://codesandbox.io/s/slate-does-not-change-its-value-1umkm?file=/src/App.js
Version 0.66.0 (ok): https://codesandbox.io/s/slate-does-change-its-value-bu6w6

Steps
To reproduce the behaviour:

  1. Go to the sandbox
  2. Click on the button
  3. See wrong behaviour

Expectation
We should be able to set the editors value to any value and the editor must render it accordingly.

Environment

  • Slate Version: As described above
  • Operating System: macOS 11.6.1
  • Browser: Chrome Version 96.0.4664.55 (Official Build) (x86_64)
@delijah delijah added the bug label Nov 25, 2021
@delijah delijah changed the title The editor does not get updated when changing the value/document The editor does not get updated when changing the value Nov 25, 2021
@delijah delijah changed the title The editor does not get updated when changing the value The editor does not get updated when changing its value Nov 25, 2021
@dylans
Copy link
Collaborator

dylans commented Nov 25, 2021

This is a deliberate change. Please see the discussion in #4540 and let us know if you have any questions. Thanks!

@delijah
Copy link
Contributor Author

delijah commented Dec 7, 2021

Ok i see. Is there a final recommendation how to handle updates from outside the component if we want to do that? By overwriting editor.children or by adding a key prop to the Slate component or another approach?

@jmorganmartin
Copy link

jmorganmartin commented Dec 15, 2021

@delijah I've seen recommendations for both key and editor.children methods. Release notes for 0.67 suggest editor.children: https://github.com/ianstormtaylor/slate/releases/tag/slate-react%400.67.0

@tamilvendhank-helptap
Copy link

@jmorganmartin, do you have a code samples of the recommended methods. Both, setting key & editor.children does not work!!

@TrySpace
Copy link

TrySpace commented Oct 3, 2024

I had to resort to setting key={JSON.stringify(value)} on the <Plate component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants