Open ehsankh1370 opened 2 months ago
That's correct and it happens on Plate JS as well. Some of my findings are here: https://github.com/udecode/plate/discussions/3584
To re-iterate:
When pressing backspace on an empty editor (in iOS), it deletes the entire Slate DOM structure inside my editor, which eventually crashes after. Any idea why this is happening? I tried deleting all plugins and it still happens. Ideally, if there's no more text, it should not delete the default <p>
tag and underlying Slate elements, but it does so any way.
See below: How an empty editor DOM looks before pressing backspace
How it looks after pressing backspace (the entire DOM inside `contenteditable is empty)
I'm using PlateJS v36.x. I added a keydown handler and returned false if editor.children = [{ type: p, children: [{ text: '' }] }]
this works but there has to better way? Would like to know what's causing this on iOS? Works fine on other platforms.
Steps to reproduce:
gh repo clone ianstormtaylor/slat
yarn install && yarn build
site/examples/ts/richtext.tsx
and delete placeholder
prop from line 50yarn start
https://localhost:3000/examples/richtext
in SafariEditor will crash with following error: Error: Cannot resolve a Slate point from DOM point: [object HTMLDivElement],0
Findings: Adding a placeholder
prop to <Editable>
reduces the occurrence by a lot but it still happens occasionally.
The issue originates from slate-react@v0.103.0
onwards so I am guessing the culprit might be
@ehsankh1370 Maybe change the issue title to iOS Safari backspace issue: Cannot resolve a Slate point from DOM point
for better visibility.
Description Only in ios safari when i type some content in the editor and HOLD backspace button to remove the content and then i write again i get "Cannot resolve a Slate point from DOM point" error. after receiving this error no removing action (backspace) is not working. this issue is happening even in the slate demo link here
Steps To reproduce the behavior:
Expectation i expect to type and remove whenever i type and tap or hold backspace
Environment