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

when updating value of Editor with api returned data it doesn't update or retender to show that data in editor, was working fine with slate-react@0.65.2 but updating version greater > 0.65.2 introduced this issue. #4710

Closed
sanj44 opened this issue Dec 3, 2021 · 7 comments
Labels

Comments

@sanj44
Copy link

sanj44 commented Dec 3, 2021

when updating value of Editor with api returned data or load from local storage it doesn't update or retender to show that data in editor, was working fine with slate-react@0.65.2 but updating version greater > 0.65.2 introduced this issue.

@sanj44 sanj44 added the bug label Dec 3, 2021
@gaKoltai
Copy link

gaKoltai commented Dec 14, 2021

Have the same issue, except that 0.66.5 works fine. Updated to 0.72.0, and the editor stopped updating its rendered value when value was changed dynamically (eg. get a certain value from list on click on a different element would still display the previously clicked element's value). These are all local state in a useReducer hook, though the whole "list" is fetched from an API at some point but not during the onClick event.

@GMkonan
Copy link

GMkonan commented Dec 16, 2021

Same issue here. Editor is not rendering updated value (like loaded data from previously saved file).

@dylans
Copy link
Collaborator

dylans commented Dec 16, 2021

Please look at closed issues such as #4689 before opening a roughly identical issue.

The discussion in #4540 explains the reason for the change in behavior (it didn't actually work reliably).

@dylans dylans closed this as completed Dec 16, 2021
@jasperoosthoek
Copy link

I ran into this issue too and solved it this way :

  editor.children = content; // <--- This line does the trick
  return (
    <Slate
      editor={editor}
      value={content}
    >
      <Editable
        renderElement={renderElement}
        renderLeaf={renderLeaf}
        autoFocus
        readOnly={true}
      />
    </Slate>
  )

Setting editor.children = content makes it work, however, setting editor={{ ...editor, children: content }} in the Slate component will not work even though this appears to do the same.

Hope this helps.

@adrianmgil
Copy link

Does it break when you add the hyperlink text in?

It does not work here when I use the editor.children = value;
slate: "^0.82.1"
slate-history: "^0.66.0"
slate-react: "^0.83.1"

@lostboy
Copy link

lostboy commented Nov 4, 2022

This is driving me insane. useResetPlateEditor no long clears the editor, nor does editor.children = []. With the latest version is there any way left to programmatically set or clear the editor value both the underlaying data and visually?

@BitPhinix
Copy link
Contributor

BitPhinix commented Nov 4, 2022

You can either manually call onChange after setting the editor value to the new content (not recommended as this will mess with location refs etc.) or remove the old and insert the new content using Transforms.removeNodes/Transforms.insertNodes etc. or remount the slate component with the new content by changing it's key prop

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

8 participants