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

Error: Cannot resolve a Slate point from DOM point #3903

Closed
kien5436 opened this issue Oct 6, 2020 · 8 comments
Closed

Error: Cannot resolve a Slate point from DOM point #3903

kien5436 opened this issue Oct 6, 2020 · 8 comments

Comments

@kien5436
Copy link

kien5436 commented Oct 6, 2020

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

bug

Reproduce

Screencast-2020-10-06-173928

See sandbox: https://codesandbox.io/s/youthful-boyd-z3l36

What's the current behavior?

Tested on Firefox and Chrome, the error only appears in Firefox
From getting started guide, I set up as the docs.
When typed something, some characters of the text was missing
When pressed enter or backspace, nothing happened
The browser console logged this:

Error: Cannot resolve a Slate point from DOM point
...

Slate: 0.59.0
Browser: Firefox 80
OS: Ubuntu 20.04

What's the expected behavior?

Works as Chrome

@karlshea
Copy link

I'm running into this too—this isn't a great entry into this project. I'd like to replace react-quill with Slate and the most simple example from the installation guide immediately crashes.

@karlshea
Copy link

karlshea commented Jan 1, 2021

I think I figured this out: SlateDocument cannot be empty.

If I initialize it with this it works:

[
  {
    children: [
      {
        type: 'paragraph',
        children: [{ text: '' }],
      },
    ],
  },
]

@kien5436
Copy link
Author

kien5436 commented Jan 2, 2021

It's because of onBeforeInput event is not implemented (see preactjs/preact#1422). I haven't found any solution for this

@BrentFarese
Copy link
Collaborator

I cannot reproduce this and am not sure there is any bug. Can you provide a minimal reproduction? As mentioned, make sure the Slate value is set. Thanks.

@kien5436
Copy link
Author

kien5436 commented Feb 7, 2021

I cannot reproduce this and am not sure there is any bug. Can you provide a minimal reproduction? As mentioned, make sure the Slate value is set. Thanks.

I did provide a code sandbox. The last time I tested on Firefox 86, Chrome 85 and Edge Chromium 90, it worked on Firefox and Chrome. I also checked your examples, they worked all, that very weird!
This is a browser problem, as I said in the previous comment (and it also has one issue here). So far I haven't found any polyfill of onBeforeInput event to support old browser versions

@BrentFarese
Copy link
Collaborator

Thank you. Yes I tried the code sandbox and couldn't reproduce any error. It seemed to work just fine. Will close for now but glad to re-open if you can provide a minimal reproduction.

@karlshea
Copy link

karlshea commented Feb 7, 2021

In the provided sandbox if I change the value hook to

const [value, setValue] = useState([]);

And click into where the editor is, I get the exception in Chrome 88.

Edit: unless that's what you meant by "make sure the Slate value is set". In my codebase I'm ensuring there's an empty paragraph and all seems to be working fine.

@souljuse
Copy link

I have the same issue, and I can reproduce on @karlshea's sandbox

It happens randomly when I type a special character, or a list of special characters, both on Firefox 90.0 (64-bit) and Chrome Version 91.0.4472.164 (Official Build) (x86_64)

2021-07-27 16 43 47

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

No branches or pull requests

4 participants