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

Slate Editor Crashing semi randomly #7152

Open
DavidWells opened this issue Mar 19, 2024 · 3 comments
Open

Slate Editor Crashing semi randomly #7152

DavidWells opened this issue Mar 19, 2024 · 3 comments
Labels
area: extensions/widgets/markdown type: bug code to address defects in shipped code

Comments

@DavidWells
Copy link
Contributor

Describe the bug

Slate editor crashes randomly with Error: Cannot resolve a DOM node from Slate node: {"text":""}

I've managed to track this down and reproduce it on https://demo.decapcms.org/#/collections/posts/entries/2024-03-20-post-number-20

To Reproduce

  1. Go to editor https://demo.decapcms.org/#/collections/posts/entries/2024-03-20-post-number-20
  2. In the body editor hit Shift + return and shift + return again, then they and delete that line
  3. Editor crashes
editor.crashing.mp4

Expected behavior
No crashes

Related

This was the only reference I could find for this error ianstormtaylor/slate#3930 but I'm unclear on how to resolve.

@DavidWells DavidWells added the type: bug code to address defects in shipped code label Mar 19, 2024
@DavidWells
Copy link
Contributor Author

DavidWells commented Mar 19, 2024

Maybe it's the <br> tag that is being inserted via

function Break(props) {
return <br {...props.attributes} />;
}
with no children as described in ianstormtaylor/slate#3930

Might need to do something like

function Break(props) {
  return <><br {...props.attributes} />{props.children}</>;
}

@DavidWells
Copy link
Contributor Author

I tested it out by changing br to a div that gets the children. It seemed to worked (no more editor crash)

div.as.br.tag.mp4

I think all the components in https://github.com/decaporg/decap-cms/blob/6266ccc16a8a992695d4bdf13a63746986cedc3e/packages/decap-cms-widget-markdown/src/MarkdownControl/renderers.js might need to render out {props.children} for slate to not throw when nodes get deleted.

DavidWells added a commit to DavidWells/decap-cms that referenced this issue Mar 19, 2024
demshy added a commit that referenced this issue Mar 28, 2024
* Potential Fix for #7152

* fix: update e2e tests for soft breaks

---------

Co-authored-by: Anze Demsar <anze.demsar@p-m.si>
yuri-g-taboola referenced this issue in taboola/decap-cms May 22, 2024
* Potential Fix for #7152

* fix: update e2e tests for soft breaks

---------

Co-authored-by: Anze Demsar <anze.demsar@p-m.si>
@demshy
Copy link
Member

demshy commented Aug 7, 2024

In 3.2.1 the lose of focus after backspacing from multiple shift+return's should also be fixed, do you mind testing again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: extensions/widgets/markdown type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

3 participants