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

Android autocorrect flickers and does not provide the right suggestions #4531

Open
churichard opened this issue Sep 17, 2021 · 1 comment
Open

Comments

@churichard
Copy link

Description
When typing on Android, the autocorrect suggestions flicker and constantly get switched out with other buttons on the toolbar (e.g. gif button, sticker button, etc.).

Also, the autocorrect suggestions that are provided are not the ones that would be provided in a native input. You can test this by typing in something, observing the suggestions, and then typing the same thing in the address bar. You can also see this at the very end of the recording, where I type in "worjs" and you don't get the "works" autocorrect suggestion in the toolbar. Not sure why this happens, but it could be because the context is being lost somehow.

Recording
https://user-images.githubusercontent.com/4218237/133834141-b1d022dd-7fb5-41ad-8bfe-50fe04737553.mp4

Sandbox
Reproducible anywhere, but I was using https://www.slatejs.org/examples/markdown-shortcuts

Steps
To reproduce the behavior:

  1. Go to https://www.slatejs.org/examples/markdown-shortcuts
  2. Start typing
  3. Observe that the autocorrect suggestions flicker
  4. Start typing a word (like "there")
  5. Observe that the autocorrect suggestions do not make sense

Expectation
The autocorrect suggestions should not flicker, and the autocorrect suggestions should be the same as if typing in a regular contenteditable or text box.

Environment

  • Slate Version: 0.66.1
  • Operating System: Android 11 (Pixel 3XL)
  • Browser: Chrome
@BitPhinix
Copy link
Contributor

BitPhinix commented Dec 2, 2021

A quick and dirty way to solve this is to patch react-dom to not set the textContent if the current value equals what it'll be set to:

In https://github.com/facebook/react/blob/ed00d2c3d8e39c214bb749dc8a520a4a695c19fd/packages/react-dom/src/client/ReactDOMHostConfig.js#L461

update

export function commitTextUpdate(
  textInstance: TextInstance,
  oldText: string,
  newText: string,
): void {
  textInstance.nodeValue = newText;
}

to

export function commitTextUpdate(
  textInstance: TextInstance,
  oldText: string,
  newText: string,
): void {
  if (textInstance.nodeValue !== newText) {
    textInstance.nodeValue = newText;
  }
}

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

No branches or pull requests

2 participants