Skip to content

Commit

Permalink
Initial fix for text insertion bugs in Android 5.1 (facebookarchive#1033
Browse files Browse the repository at this point in the history
)

Related to issue facebookarchive#1011

There is a bug in Android 5.1 (not 5.0 oddly enough) that makes text
entry nearly unusable. It's documented in detail here -
facebookarchive#1011

Logging everything shows that;
 - when we have a block with text and spaces, and start deleting the
   characters one by one, there is an 'onInput' for each deletion that
   updates the text.
 - when you delete the very last character, the 'anchorNode' of the
   domSelection has a type that is not a text node. So we skip updating
   at all, and that means the last character doesn't actually get
   properly deleted from editorState.
 - Then the next time something fully updates the editorState, that last
   character shows up again.

The root issue is that Android 5.1, when we tested it, was in
"composition" mode and the current handlers are not really built to
handle text deletion properly in composition mode.

We're looking forward to finding a more complete solution to the root
cause - for now this change improves the usability on mobile and doesn't
break anything.
  • Loading branch information
flarnie authored and ouchxp committed Apr 7, 2017
1 parent 361f811 commit dd69798
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/component/handlers/edit/editOnInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ function editOnInput(editor: DraftEditor): void {
var domSelection = global.getSelection();

var {anchorNode, isCollapsed} = domSelection;
if (anchorNode.nodeType !== Node.TEXT_NODE) {

const isNotTextOrElementNode = anchorNode.nodeType !== Node.TEXT_NODE
&& anchorNode.nodeType !== Node.ELEMENT_NODE;
if (isNotTextOrElementNode) {
return;
}

Expand Down

1 comment on commit dd69798

@abhinavsingi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flarnie When will you release this? Can you please tell an eta on that?

Please sign in to comment.