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

"Cannot resolve a Slate point from DOM point" #5711

Open
ehsankh1370 opened this issue Sep 1, 2024 · 3 comments
Open

"Cannot resolve a Slate point from DOM point" #5711

ehsankh1370 opened this issue Sep 1, 2024 · 3 comments
Labels

Comments

@ehsankh1370
Copy link

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:

  1. in ios safari Go to https://www.slatejs.org/examples/richtext
  2. remove the whole content while HOLDING backspace
  3. then try to type some characters
  4. and then try to remove( tap or hold backspace) - and you see Cannot resolve a Slate point from DOM point error in the console
  5. then you see that nothing is going to be removed

Expectation
i expect to type and remove whenever i type and tap or hold backspace

Environment

  • Slate Version: [0.103.0]
  • Operating System: [iOS]
  • Browser: [Safari]
@ehsankh1370 ehsankh1370 added the bug label Sep 1, 2024
@abhi-bc
Copy link

abhi-bc commented Oct 25, 2024

That's correct and it happens on Plate JS as well. Some of my findings are here: udecode/plate#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
Screenshot 2024-09-25 at 4 31 39 PM

How it looks after pressing backspace (the entire DOM inside `contenteditable is empty)
Screenshot 2024-09-25 at 4 33 26 PM

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:

  1. Clone gh repo clone ianstormtaylor/slat
  2. yarn install && yarn build
  3. Open site/examples/ts/richtext.tsx and delete placeholder prop from line 50
  4. yarn start
  5. Start iOS simulator, open https://localhost:3000/examples/richtext in Safari
  6. Keep pressing backspace on iOS soft keyboard until everything is gone. Press a few more times when it's empty
  7. Try to type anything now

Editor will crash with following error: Error: Cannot resolve a Slate point from DOM point: [object HTMLDivElement],0
Screenshot 2024-10-25 at 10 00 43 AM

Findings: Adding a placeholder prop to <Editable> reduces the occurrence by a lot but it still happens occasionally.

The issue originates from [email protected] onwards so I am guessing the culprit might be

  1. Version Packages #5626, OR
  2. Add Safari workaround inside shadow DOM. #5648

@abhi-bc
Copy link

abhi-bc commented Oct 25, 2024

@ehsankh1370 Maybe change the issue title to iOS Safari backspace issue: Cannot resolve a Slate point from DOM point for better visibility.

@washanhanzi
Copy link

#5762

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants