Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Android will loose focus if the contenteditable field is redrawn. This forces keyboard close.#572

Closed
butchmarshall wants to merge 1 commit intofacebookarchive:masterfrom
butchmarshall:android-keep-focus
Closed

Android will loose focus if the contenteditable field is redrawn. This forces keyboard close.#572
butchmarshall wants to merge 1 commit intofacebookarchive:masterfrom
butchmarshall:android-keep-focus

Conversation

@butchmarshall
Copy link

Android will loose focus if the contenteditable="true" field is also redrawn.

This restricts forcing redraw to the only the element instead of redrawing the contenteditable="true" element.

@butchmarshall butchmarshall mentioned this pull request Jul 29, 2016
4 tasks
@butchmarshall butchmarshall changed the title Android will loose focus if the contenteditable field is redrawn, for… Android will loose focus if the contenteditable field is redrawn. This forces keyboard close. Jul 29, 2016
@ghost ghost added the CLA Signed label Jul 29, 2016
@sophiebits
Copy link
Contributor

Hm. I'm worried that there could be other children of the contenteditable div in the DOM that wouldn't get removed if we only rekey the contents component.

@butchmarshall
Copy link
Author

butchmarshall commented Jul 29, 2016

I was wondering if there were any children not in the content="true" element @spicyj - thanks for the clarification.

Would a more targeted updating method work?

Right now I'm thinking:

  • add a second key
  • determine if we're inputting from a virtual-keyboard
  • re-key only content="true" div if this is the case?
  • else re-key everything

@ghost ghost added the CLA Signed label Jul 29, 2016
@butchmarshall butchmarshall force-pushed the android-keep-focus branch 2 times, most recently from 4bb7dab to f18c84e Compare August 2, 2016 11:57
@ghost ghost added the CLA Signed label Aug 2, 2016
@ghost ghost added the CLA Signed label Aug 2, 2016
@codejet
Copy link

codejet commented Aug 3, 2016

Is there any chance of this getting merged sometime soon?

@butchmarshall
Copy link
Author

butchmarshall commented Aug 3, 2016

Hey @codejet, the concern here is we're not sure if this is the proper fix. It fixes the keyboard issue, but because of the more targeted redraw we need to make sure it doesn't cause any other issues.

@ghost ghost added the CLA Signed label Aug 3, 2016
@hellendag
Copy link

I don't think there should be any other children of the contentEditable div. As it is, I think I only pulled DraftEditorContents out into a separate component for shouldComponentUpdate purposes.

I'm actually wondering if it would always be safe to redraw only the DraftEditorContents when resetting the DOM.

  • The reset behavior is only needed for cut and composition events.
  • These events should only occur to contents that are definitely within the contentEditable.
  • These events should only occur on descendants of DraftEditorContents.

The case where I can see problems occurring is where a cut or composition discards the entire DraftEditorContents for some reason.

Would you mind giving this a try and going through the cut/composition parts of the manual test plan to see if it works?

@sophiebits
Copy link
Contributor

It seems like select all then cut would delete the contents completely…

@dortzur
Copy link

dortzur commented Dec 29, 2016

Dear god, please merge this

@dortzur
Copy link

dortzur commented Dec 29, 2016

FYI Googlers: I was able to sidestep this problem by by disabling autocorrect on the contentdeditable element on Android.
https://davidwalsh.name/disable-autocorrect

@tonygentilcore
Copy link
Contributor

@hellendag Your suggestion about only redrawing DraftEditorContents works like a charm. Here's a PR for that approach: #907

@flarnie flarnie self-assigned this Feb 10, 2017
@aaren-cordova
Copy link

May want to also check out #907, looks like it tackles the same issue with a similar fix.

@flarnie
Copy link
Contributor

flarnie commented Sep 29, 2017

We ended up merging a similar PR - #907 so closing this.

@flarnie flarnie closed this Sep 29, 2017
robbertbrak added a commit to robbertbrak/draft-js that referenced this pull request Apr 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants