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

serializeHtml causes editor.children to become [] #2796

Closed
12joan opened this issue Dec 9, 2023 · 1 comment · Fixed by #2797
Closed

serializeHtml causes editor.children to become [] #2796

12joan opened this issue Dec 9, 2023 · 1 comment · Fixed by #2797
Labels
bug Something isn't working plugin:serialize-html

Comments

@12joan
Copy link
Collaborator

12joan commented Dec 9, 2023

Description

When calling serializeHtml on editor.children, editor.children becomes []. The editor component doesn't rerender immediately, so this problem only becomes apparent when focusing the editor and attempting to type, which results in an error.

Most likely caused by @udecode/[email protected] (CC @dimaanj)

🧵 Discord thread

Steps to Reproduce

  1. Go to the code sandbox
  2. Verify that typing works normally
  3. Click the button to call serializeHtml
  4. Refocus the editor and try to type

Sandbox

https://codesandbox.io/p/devbox/eloquent-albattani-forked-kl3qlc?file=%2Fpackage.json

Environment

  • slate: 0.101.1
  • slate-react: 0.101.3
  • browser: firefox
  • @udecode/plate-serialize-html: >= 26.0.0

Bounty

Click here to add a bounty via Algora.

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@12joan 12joan added bug Something isn't working plugin:serialize-html labels Dec 9, 2023
@12joan
Copy link
Collaborator Author

12joan commented Dec 9, 2023

I think the problem is this line, where we pass the live editor to createElementWithSlate. Previously, createElementWithSlate created a fresh editor instance, so any side effects wouldn't mutate the live editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin:serialize-html
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant