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

insertText after addMark/removeMark will carsh #3708

Open
wangqs1990 opened this issue May 30, 2020 · 2 comments · May be fixed by #5407
Open

insertText after addMark/removeMark will carsh #3708

wangqs1990 opened this issue May 30, 2020 · 2 comments · May be fixed by #5407

Comments

@wangqs1990
Copy link

Do you want to request a feature or report a bug?

bug

What's the current behavior?

insertText after addMark or removeMark in a React event handler, the editor will crash

editor

code example:
https://codesandbox.io/s/slate-addmark-leggp

Slate: 0.58.1
Browser: Chrome
OS: Mac

What's the expected behavior?

It may be caused by addMark function call editor.onChange sync and apply function call it in a microtask. conflict with lazy state update in React synthetic events
https://github.com/ianstormtaylor/slate/blob/master/packages/slate/src/create-editor.ts#L109

@flakekun
Copy link

flakekun commented Dec 2, 2020

I'm experiencing the same crash behavior but in a different environment. It almost never happens in Chrome 87, but always happening in Firefox 83 (both on Mac and Windows).

@Xheldon
Copy link
Contributor

Xheldon commented Jan 19, 2021

you can use requestAnimationFrame to fix this error, just put the insertText in requestAnimationFrame callback.

@zbeyens zbeyens linked a pull request Apr 27, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants