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

Android Web has Known Issues [Compilation of other issues] #1895

Closed
flarnie opened this issue Oct 14, 2018 · 11 comments
Closed

Android Web has Known Issues [Compilation of other issues] #1895

flarnie opened this issue Oct 14, 2018 · 11 comments

Comments

@flarnie
Copy link
Contributor

flarnie commented Oct 14, 2018

tdlr: Draft.js does not work correctly with some combinations of Android keyboards and mobile web browsers.

More details below:

Why was my issue merged into this one?

We know there are problems with Draft.js on mobile Android browsers, and merging all Android bug reports into one place keeps things organized and reduces noise.

Why is Draft.js broken on some Android phones?

Some Android keyboards do not send standard keyboard input events, and the information about what happened during the input is missing in the event data. As reported in issue #1067,
"When backspacing using some Android keyboards such as the Google keyboard, no key events are fired and no key codes are provided by the input event data when editOnInput gets called."
Also in general, we continue to encounter quirks and differences in general with Android web compared to other web platforms, and maintainers agree that it would require a rewrite of some parts of Draft.js in order to address the problem.

When will this be fixed?

Facebook maintainers are currently prioritizing other bug fixes and improvements, and we believe this problem will require a large investment to fully fix. So for now it's not being fixed.

This sucks and it's awful!!!!111

I agree, it's really a shame. Sorry we have not been able to fix it. Maintainers internally and externally have made several attempts, but none have been successful. Feel free to work on this in a fork if you are interested though! That's part of the beauty of Open source; you can take this code and make it better, and nobody can stop you.

Any work-arounds?

We would love help from an external contributor to write a guide on this. Some of the issues listed below have comments suggesting various hacks, but there is not an organized guide at this point.

What are the specific known bugs?

We will continue periodically to update this list with any new reports.

@chrbala
Copy link

chrbala commented Oct 21, 2018

Has anyone worked on getting a fallback scenario to a simple text input for Android? In some Android browsers, text does not propagate to the input field. I would like to work toward using Draft.js for progressive enhancement in browsers it does support well, but am unsure of how to reliably detect when I should fall back.

@Fi1osof
Copy link

Fi1osof commented Nov 17, 2018

+1

1 similar comment
@leofrozenyogurt
Copy link

+1

@JanBussieck
Copy link

Given these persistent problems on Android, I am wondering what facebook does internally to address the problem. From a casual look at the page source, it seems like Draft-js is still in use on facebook.com, is there some fallback for Android? And if so, why wouldn't it be integrated into Draft-js?

Thanks :)

@srosset81
Copy link

@JanBussieck I don't think Facebook use Draft.js in production (I believe this is what implies this comment: #102 (comment))

@kayhadrin
Copy link

Well as far as I know, we at FB don't use it on mobile due to the aforementioned issues.

@JLarky
Copy link

JLarky commented Jan 31, 2019

Given these persistent problems on Android, I am wondering what facebook does internally to address the problem. From a casual look at the page source, it seems like Draft-js is still in use on facebook.com, is there some fallback for Android? And if so, why wouldn't it be integrated into Draft-js?

That was exactly my thinking :) when you open Facebook from Android it switches to textarea input, so I'm planning to do exactly that for my website as well :)

pramodsum added a commit to pramodsum/box-annotations that referenced this issue Feb 1, 2019
This duplication of ApprovalCommentForm replaces the DraftJSMentionSelector with a simple TextArea due to complications with Android autocomplete interfering with draft.js

See facebookarchive/draft-js#1895
pramodsum added a commit to pramodsum/box-annotations that referenced this issue Feb 1, 2019
This duplication of ApprovalCommentForm replaces the DraftJSMentionSelector with a simple TextArea due to complications with Android autocomplete interfering with draft.js

See facebookarchive/draft-js#1895
pramodsum added a commit to box/box-annotations that referenced this issue Feb 4, 2019
This duplication of ApprovalCommentForm replaces the DraftJSMentionSelector with a simple TextArea due to complications with Android autocomplete interfering with draft.js

See facebookarchive/draft-js#1895

- Remove all draftjs components from ApprovalCommentForm
- Upgrade BRUI to use TextArea hideLabel prop
@dminkovsky
Copy link

Does anyone have any thoughts on how to best perform the feature detection necessary run draft-js? I would like to drop down to a textarea in the event the client doesn't support the necessary features. Not sure how to best do that beyond detecting Android.

@JLarky
Copy link

JLarky commented Feb 13, 2019

Does anyone have any thoughts on how to best perform the feature detection necessary run draft-js? I would like to drop down to a textarea in the event the client doesn't support the necessary features. Not sure how to best do that beyond detecting Android.

I don't think it's about detecting features, but more about detecting bugs :) it depends on what is your manufacturer, what kind of keyboard you are using and so on. So you probably have to turn it into textarea for any Android phone and maybe add some opt-in for draft-js in case if user is sure that it works on this particular phone

@fabiomcosta
Copy link
Contributor

There has been an effort on fixing most Android composition issues, making actually work on Android at #2035
Help testing the PR is highly appreciated. There are instructions on how to do that on the PR and this codesandbox is setup with the package that has the PR applied to it: https://3ymzzlj9n5.codesandbox.io/

facebook-github-bot pushed a commit that referenced this issue May 9, 2019
Summary:
This PR is a new attempt to address #1895

On #2031 I was trying to make compositions work using the data provided by that event, and even though that works well for most operational system, that doesn't work well for Android, where you can make composition updates in multiple places on the same composition transaction.

This PR is an improvement over that PR, in that it uses a DOM mutation observer during the `compositionStart` -> `compositionEnd` interval to detect the changes the user made, and then re-apply those to the ContentState on `compositionEnd`.

This approach is the one used by [Prosemirror](http://prosemirror.net/) (see https://github.com/ProseMirror/prosemirror-view/blob/master/src/domobserver.js), which is the only Rich Text Editor I've tried that works well on Android.
Like previously mentioned, it allows multiple mutations on multiple places in the same composition transaction, which was impossible with the previous approach, and would cause DOM<->state inconsistencies in multiple use cases.

The intent of this PR is not to fix every single Android bug, but to have a consistent editing experience on Android without introducing bugs (ideally).

**TODO, known issues:**
- [x] Removing empty line breaks with <backspace> doesn’t remove blocks.
- [x] Mutations on the same block (different leaf nodes) are not being properly applied.
- [x] Selection is not properly updated during composition events
- [ ] Keep `inlineStyleOverride` working with a consistent behavior

**TODO, others:**
- [x] Test on Android Pie v9 API 28
- [x] Test on Android Oreo v8.1 API 27
- [x] Test on Android Oreo v8.0 API 26
- [x] Test on iPhone 12.1 (with Japanese Kana keyboard)
- [x] Test composition events on Chrome Desktop v73
- [x] Test composition on IE11 (I didn't know how to test composition events though)
- [x] Unit tests

There are 3 ways to try out this PR.

Codesandbox: https://3ymzzlj9n5.codesandbox.io/ (uses `draft-js-android-fix-beta.3`)

Use the published [draft-js-android-fix](https://www.npmjs.com/package/draft-js-android-fix) package: `yarn install draft-js-android-fix`

Note that this package might not be up-to-date, it's hard for me to guarantee I'll always remember to update the package, but I'll do my best.

The other way is guaranteed to be up-to-date, but has a longer setup:
* run `git clone https://github.com/facebook/draft-js.git`
* run `git remote add fabiomcosta https://github.com/fabiomcosta/draft-js.git`
* run `git fetch fabiomcosta`
* run `git checkout -b attempt_android_fix_with_dom_diff fabiomcosta/attempt_android_fix_with_dom_diff`
* run `yarn install` (or use `npm`)
* run `open examples/draft-0-10-0/rich/rich.html`, or any other example you'd like to test
Pull Request resolved: #2035

Reviewed By: kedromelon

Differential Revision: D14568528

Pulled By: claudiopro

fbshipit-source-id: 16861de52eca41cd98f884b0aecf034213fc1bd0
@claudiopro
Copy link
Contributor

This was addressed with #2035, thank you @fabiomcosta. Y'all, feel free to open a new issue if there are still glitches with Android editing.

jdecked pushed a commit to twitter-forks/draft-js that referenced this issue Oct 9, 2019
Summary:
This PR is a new attempt to address facebookarchive#1895

On facebookarchive#2031 I was trying to make compositions work using the data provided by that event, and even though that works well for most operational system, that doesn't work well for Android, where you can make composition updates in multiple places on the same composition transaction.

This PR is an improvement over that PR, in that it uses a DOM mutation observer during the `compositionStart` -> `compositionEnd` interval to detect the changes the user made, and then re-apply those to the ContentState on `compositionEnd`.

This approach is the one used by [Prosemirror](http://prosemirror.net/) (see https://github.com/ProseMirror/prosemirror-view/blob/master/src/domobserver.js), which is the only Rich Text Editor I've tried that works well on Android.
Like previously mentioned, it allows multiple mutations on multiple places in the same composition transaction, which was impossible with the previous approach, and would cause DOM<->state inconsistencies in multiple use cases.

The intent of this PR is not to fix every single Android bug, but to have a consistent editing experience on Android without introducing bugs (ideally).

**TODO, known issues:**
- [x] Removing empty line breaks with <backspace> doesn’t remove blocks.
- [x] Mutations on the same block (different leaf nodes) are not being properly applied.
- [x] Selection is not properly updated during composition events
- [ ] Keep `inlineStyleOverride` working with a consistent behavior

**TODO, others:**
- [x] Test on Android Pie v9 API 28
- [x] Test on Android Oreo v8.1 API 27
- [x] Test on Android Oreo v8.0 API 26
- [x] Test on iPhone 12.1 (with Japanese Kana keyboard)
- [x] Test composition events on Chrome Desktop v73
- [x] Test composition on IE11 (I didn't know how to test composition events though)
- [x] Unit tests

There are 3 ways to try out this PR.

Codesandbox: https://3ymzzlj9n5.codesandbox.io/ (uses `draft-js-android-fix-beta.3`)

Use the published [draft-js-android-fix](https://www.npmjs.com/package/draft-js-android-fix) package: `yarn install draft-js-android-fix`

Note that this package might not be up-to-date, it's hard for me to guarantee I'll always remember to update the package, but I'll do my best.

The other way is guaranteed to be up-to-date, but has a longer setup:
* run `git clone https://github.com/facebook/draft-js.git`
* run `git remote add fabiomcosta https://github.com/fabiomcosta/draft-js.git`
* run `git fetch fabiomcosta`
* run `git checkout -b attempt_android_fix_with_dom_diff fabiomcosta/attempt_android_fix_with_dom_diff`
* run `yarn install` (or use `npm`)
* run `open examples/draft-0-10-0/rich/rich.html`, or any other example you'd like to test
Pull Request resolved: facebookarchive#2035

Reviewed By: kedromelon

Differential Revision: D14568528

Pulled By: claudiopro

fbshipit-source-id: 16861de52eca41cd98f884b0aecf034213fc1bd0
mmissey pushed a commit to mmissey/draft-js that referenced this issue Mar 24, 2020
Summary:
This PR is a new attempt to address facebookarchive#1895

On facebookarchive#2031 I was trying to make compositions work using the data provided by that event, and even though that works well for most operational system, that doesn't work well for Android, where you can make composition updates in multiple places on the same composition transaction.

This PR is an improvement over that PR, in that it uses a DOM mutation observer during the `compositionStart` -> `compositionEnd` interval to detect the changes the user made, and then re-apply those to the ContentState on `compositionEnd`.

This approach is the one used by [Prosemirror](http://prosemirror.net/) (see https://github.com/ProseMirror/prosemirror-view/blob/master/src/domobserver.js), which is the only Rich Text Editor I've tried that works well on Android.
Like previously mentioned, it allows multiple mutations on multiple places in the same composition transaction, which was impossible with the previous approach, and would cause DOM<->state inconsistencies in multiple use cases.

The intent of this PR is not to fix every single Android bug, but to have a consistent editing experience on Android without introducing bugs (ideally).

**TODO, known issues:**
- [x] Removing empty line breaks with <backspace> doesn’t remove blocks.
- [x] Mutations on the same block (different leaf nodes) are not being properly applied.
- [x] Selection is not properly updated during composition events
- [ ] Keep `inlineStyleOverride` working with a consistent behavior

**TODO, others:**
- [x] Test on Android Pie v9 API 28
- [x] Test on Android Oreo v8.1 API 27
- [x] Test on Android Oreo v8.0 API 26
- [x] Test on iPhone 12.1 (with Japanese Kana keyboard)
- [x] Test composition events on Chrome Desktop v73
- [x] Test composition on IE11 (I didn't know how to test composition events though)
- [x] Unit tests

There are 3 ways to try out this PR.

Codesandbox: https://3ymzzlj9n5.codesandbox.io/ (uses `draft-js-android-fix-beta.3`)

Use the published [draft-js-android-fix](https://www.npmjs.com/package/draft-js-android-fix) package: `yarn install draft-js-android-fix`

Note that this package might not be up-to-date, it's hard for me to guarantee I'll always remember to update the package, but I'll do my best.

The other way is guaranteed to be up-to-date, but has a longer setup:
* run `git clone https://github.com/facebook/draft-js.git`
* run `git remote add fabiomcosta https://github.com/fabiomcosta/draft-js.git`
* run `git fetch fabiomcosta`
* run `git checkout -b attempt_android_fix_with_dom_diff fabiomcosta/attempt_android_fix_with_dom_diff`
* run `yarn install` (or use `npm`)
* run `open examples/draft-0-10-0/rich/rich.html`, or any other example you'd like to test
Pull Request resolved: facebookarchive#2035

Reviewed By: kedromelon

Differential Revision: D14568528

Pulled By: claudiopro

fbshipit-source-id: 16861de52eca41cd98f884b0aecf034213fc1bd0
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests