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

Cannot type Chinese in Edge #2082

Closed
robbertbrak opened this issue May 22, 2019 · 2 comments
Closed

Cannot type Chinese in Edge #2082

robbertbrak opened this issue May 22, 2019 · 2 comments
Labels
edge Issues related to Microsoft Edge browser IME

Comments

@robbertbrak
Copy link
Contributor

To reproduce:

  • Use the latest version of Draft (i.e., one that includes 634bd29)
  • In Microsoft Edge, open the rich text example
  • Switch to Chinese, with the standard Microsoft IME.
  • Type nihao1

Result: the text disappears. See the below screencast:

screencast 2019-05-22 17-24-08

Note that it does work correctly when the block already contains some text.

@robbertbrak
Copy link
Contributor Author

When I change https://github.com/facebook/draft-js/blob/master/src/component/handlers/composition/DOMObserver.js#L120 from

if (removedNodes && removedNodes.length) {
  return '';
}

to

if (removedNodes && removedNodes.length) {
  return '';
} else if (target.textContent !== '') {
  return target.textContent;
}

This appears to be working correctly. Some preliminary testing seems to indicate that it also works on Android, and on browsers other than Edge, but I might be missing something.

@fabiomcosta: I'd be very interested in hearing your thoughts on this. Do you think this fix is in the right direction?

@fabiomcosta
Copy link
Contributor

Hi @robbertbrak thank you so much for looking further and finding a fix!
The fix looks fine to me, this path is supposed to handle cases when you are removing blocks, ex:

draft-js
r[carret]

Now removing "r" and going back to the previous like by pressing Backspace 2 times should create the proper draft-js EditorState.

I'm just providing this as a test case so you can make sure no bugs are introduced in this case. By looking at your code, I don't there will be though, the fix looks pretty safe to me.

Do you want to go ahead and create a PR?

cc @claudiopro

robbertbrak added a commit to robbertbrak/draft-js that referenced this issue May 24, 2019
robbertbrak added a commit to robbertbrak/draft-js that referenced this issue May 28, 2019
@claudiopro claudiopro added edge Issues related to Microsoft Edge browser IME labels Sep 25, 2019
mmissey pushed a commit to mmissey/draft-js that referenced this issue Mar 24, 2020
Summary:
Fixes facebookarchive#2082.
Pull Request resolved: facebookarchive#2088

Differential Revision: D18698264

Pulled By: mrkev

fbshipit-source-id: f5f5d4e4a0ff66a9fef62976af8726660411a106
vilemj-Viclick pushed a commit to kontent-ai/draft-js that referenced this issue Jul 16, 2020
Summary:
Fixes facebookarchive#2082.
Pull Request resolved: facebookarchive#2088

Differential Revision: D18698264

Pulled By: mrkev

fbshipit-source-id: f5f5d4e4a0ff66a9fef62976af8726660411a106
alicayan008 pushed a commit to alicayan008/draft-js that referenced this issue Jul 4, 2023
Summary:
Fixes facebookarchive/draft-js#2082.
Pull Request resolved: facebookarchive/draft-js#2088

Differential Revision: D18698264

Pulled By: mrkev

fbshipit-source-id: f5f5d4e4a0ff66a9fef62976af8726660411a106
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
edge Issues related to Microsoft Edge browser IME
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants