facebookarchive / draft-js

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

typing Korean in linux, chrome/electron is buggy #2005

Open palindrom615 opened 5 years ago

palindrom615 commented 5 years ago

Do you want to request a feature or report a bug?

bug.

What is the current behavior?

the first korean letter after compositionend event is ignored.

draft-js-kor

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?

after commit 07b1eb847fb801d61b41a7a03c7c26c80cca5478. I have tested windows and fedora 29 and the bug happened only on chrome or electron in linux fedora 29.

I think I found the reason why bug happens.

left one: jsfiddle showing order of occuring event in chrome, windows. right one: same one in linux.

at chrome in linux, beforeinput event occurs between compositionend and following compositionstart, unlike that of windows. So when typing new Korean character, beforeinput event handler of mode edit https://github.com/facebook/draft-js/blob/3400cdafb465640c41d3728d52ed59e8f13ad78a/src/component/handlers/edit/editOnBeforeInput.js#L80 is called instead of mode composite. https://github.com/facebook/draft-js/blob/3400cdafb465640c41d3728d52ed59e8f13ad78a/src/component/handlers/composition/DraftEditorCompositionHandler.js#L48

yeah that is chromium's own bug, but we can bypass the bug by not to change mode from composite to edit.

https://github.com/facebook/draft-js/blob/3400cdafb465640c41d3728d52ed59e8f13ad78a/src/component/handlers/composition/DraftEditorCompositionHandler.js#L90

The mode is changed because of invalid stillComposing flag, so by removing the if statement above, the bug fixed.

Actually, I cannot catch logic of the statement or even comments. Can @sophiebits or anyone help me understand the code? At least I cannot find any bug without that part. Maybe because I don't have any macOS...

palindrom615 commented 5 years ago

I think this issue is not so trivial because I've found some people complaining about writing facebook post or messenger with linux and chrome...

sophiebits commented 5 years ago

IIRC Safari on Mac needs that for typing to work in Korean. Unfortunately every browser sends different events and it is really hard to know what will work on all of them.

palindrom615 commented 5 years ago

@sophiebits , i just tested removed version of draft-js with macOS 10.14.1 and safari 12.0.1 and it seems no problem.

Can you share some more specific info about #666?

ujihisa commented 5 years ago

Not sure if it's same issue or not, but it also happens for Japanese with fcitx mozc (the defacto standard Japanese input method) on ArchLinux.

https://youtu.be/KOkggWX-024

realgsong commented 4 years ago

It seems it's related with https://bugs.chromium.org/p/chromium/issues/detail?id=695326

ujihisa commented 4 years ago

The current issue title might have been misleading, since it's been over a year since it's broken.

suggested change:

BEFORE: typing Korean in linux, chrome/electron is buggy AFTER: typing Korean and Japanese in linux, chrome/electron are broken

josephjang commented 4 years ago

Please note that all the electron apps that use draft.js are unusable in Linux due to this problem.

ujihisa commented 3 years ago

This is still broken for Japanese input in the latest version.