question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected text input on latest Android Mobile

See original GitHub issue

[Edit]: After creating this issue I noticed this may be a duplicate of https://github.com/ianstormtaylor/slate/issues/3112

The following is recorded using crossbrowsertesting.com with the latest android (Android Google Pixel 3 / 9.0 Chrome Mobile 77) I’ve also seen similar behavior on older versions of android and chrome mobile.

ezgif-5-2291b413293d (1)

I started noticing these issues when I was getting the following errors however I couldn’t reproduce these in development so I figured it was a device specific issue.

Object.toSlatePoint: Cannot resolve a DOM point from Slate point: {"path":[0,1,0],"offset":106} Object.toSlatePoint: Cannot resolve a Slate point from DOM point: [object Text],108

The video doesn’t directly lead to these errors however the video’s behavior is an issue in itself and I believe the errors are a result of entering text in a blank editor on those devices however clearing out the editor is nearly impossible.

Slate: 0.54 Browser: Chrome Mobile 77 OS: Android 9

May also be related: https://github.com/ianstormtaylor/slate/issues/3309

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mpkellycommented, Dec 27, 2019

FYI I am also getting this issue on Mac/Chrome 79 when using 0.57.1. It’s not blocking me though so just adding a note here in hope helps debug the issue.

I am rendering a small button into the corner of a table cell and then when that button is clicked I show a small popup menu. I then click an option, e.g. Add column, and this error is logged before my event handler fires:

Uncaught Error: Cannot resolve a Slate point from DOM point: [object Text],5

The stack trace is:

   at Object.toSlatePoint (index.es.js:1708)
    at Object.toSlateRange (index.es.js:1753)
    at HTMLDocument.eval (index.es.js:817)
    at later (index.js:27)

The error originates from this handler: onDOMSelectionChange. Inspecting the code, it looks like onDOMSelectionChange is expecting slate nodes only and not dynamic nodes like I am including.

My code looks like this. Note the dynamic nature of the menu which is included for the focused cell only

  return (
    <td {...attributes}>
      <Show when={active}>
        <div className="table-cell-menu" onClick={handleClick}>
          <ReactIcon icon={menuIcon} className="table-cell-menu-icon" />
        </div>
      </Show>
      {children}
      <Show when={showMenu}>
        <Popup {...position.current} onClose={handleClick}>
          <List items={listItems.current} />
        </Popup>
      </Show>
    </td>
  );

The UI:

image

0reactions
andrew-aladevcommented, May 19, 2020

All these issues are the same: users are trying to set new value without reseting internal selection. Slate editor have to use getDerivedStateFromProps and automatically fix or reset internal selection when new value appears (nextProps.value !== prevState.value).

These issues can be fixed by core developer of slate only, because it requires change of project design. Users can only try to reset selection in a any dirty way.

The easiest way to provide dirty hack is to find a special case which breaks internal selection and use it to recreate slate editor completely. For example:

static getDerivedStateFromProps (nextProps, prevState) {
  const result = {}

  if (nextProps.input.value !== prevState.value || ...) {
    result.value = nextProps.input.value
    result.document = getDocument(nextProps.input.value, ...)
  }

  if ((result.document == null && ...) || selectionWillBeBroken(prevState.document, result.document)) {
    result.editor = getEditor(...)
  }

  if (Object.keys(result).length !== 0) {
    return result
  }
  return null
}

render () {
  ...
  return (
    <Slate
      editor={editor}
      value={document}
      ...
  )
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Predictive text not showing after latest Android Update Version ...
So go to Settings>General management>Language and input>On-screen keyboard>Samsung keyboard. Click About Samsung keyboard. Now click the i icon ...
Read more >
Troubleshoot Voice Access - Android Accessibility Help
Before you begin troubleshooting, try the following steps to resolve your issue: Install the latest version of Voice Access.
Read more >
Solved: Text Input data not visible on mobile devices
Solved: Hi, I have several TextInput fields, the values of those fields depend on the input from other TextInput fields using the following ......
Read more >
Known issues with Android Studio and Android Gradle Plugin
To fix this issue, upgrade your Android 11 emulator to version 9 or higher by navigating to Tools > SDK Manager. In the...
Read more >
Vue watch unexpected response with Android Chrome
In a nutshell, if you are using an "input method" (Gboard on my phone with swipe does this), the input event won't be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found