slate-react 0.66.x - weird bug with next/link and passHref
See original GitHub issueDescription
we use slate and slate-react in https://github.com/react-page/react-page as the rich-content editor.
I observed a problem when updating to react-slate 0.66.x. When i add a character at the end of certain inline or mark-elements that render a next/link
with passHref
property, slate adds the character twice (once inside and once outside of the component) and sometimes crashes with a Failed to execute 'setStart' on 'Range': There is no child at offset xx.
The bug does not happen if I don’t set passHref, so i assume that passHref does some Element cloning (in order to inject href as property) and that this messes with slate.
the bug only happens when i insert a char at the end.
Recording
https://user-images.githubusercontent.com/1972353/137481690-ea3500a4-eda6-4064-a7ae-4292c4aec6e6.mov
Sandbox
not yet available
Steps
not yet available
Expectation A clear and concise description of what you expected to happen. (Often it’s helpful to test out the behavior of other editors like Google Docs, Medium, Notion, etc. to see how they handle the same issue.)
Environment
- Slate Version: 0.66.5
- Slate React Version: 0.66.0 - 0.66.7
- Operating System: macOS
- Browser: Chrome
I tried downgrading only slate-react to 0.65.x and the error disappears even with newest slate (core) version
Context
This is probably a bit tricky to reproduce and i try to add more context if i have some.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
This should be fixed with the latest releases. Please reopen if it is not. (latest slate-react is 0.69.0).
seems to be fixed in latest version, at least could not reproduce it so far.