facebookarchive / draft-js

A React framework for building text editors.
https://draftjs.org/
MIT License
22.58k stars 2.64k forks source link

[Bug] Android auto suggestion: inserts duplicate characters, hides content #911

Closed EmpireJones closed 6 years ago

EmpireJones commented 7 years ago

When I select a suggestion via the android keyboard, sometimes it inserts duplicate characters or temporarily hides the content. Reproduced on https://facebook.github.io/draft-js/

It seems to more consistently occur when you start with no text.

In this first example:

  1. Typed "Wh"
  2. "Pressed "What" suggestion
  3. "Editor showed "WhatW" videotogif_2017 01 02_18 36 46

In this second example:

  1. Typed "The following"
  2. deleted it
  3. opened keyboard
  4. pressed "The" suggestion (editor was blank)
  5. opened keyboard
  6. pressed "Hi" suggestion (editor was blank)
  7. opened keyboard
  8. typed "asdf"
  9. pressed "ASDF" suggestion
  10. editor showed "ASDFHiTheT"

videotogif_2017 01 02_18 49 33

What is the expected behavior? No invisible text or duplicate characters

draft-js 0.9.1 Android chrome version 55.0.2883.91

EmpireJones commented 7 years ago

Here's a general description of a case very similar to the first example above:

  1. Type something
  2. Delete it via backspace
  3. Type a word
  4. Press space key

Results in:

will-hart commented 7 years ago

I think some of the behaviour, i.e. the keyboard closing is related to #888 which has an un-merged PR #907.

I've also found it doesn't like adding text at the very start of the document sometimes, which is what appears to be happening in your second gif.

On Android when the word is underlined it doesn't actually appear to be in the editor - i.e. the word is not sent to my server from the onChange callback until I hit space or select an autocorrect option. I wonder if this is contributing. (edit: see #102 and #580 I think)

flarnie commented 6 years ago

Merging this into a general Android bug issue - see https://github.com/facebook/draft-js/issues/1895