Draft-js: JS .blur() on Draft editor causes in-progress composition to be lost

Created on 9 Feb 2019  路  2Comments  路  Source: facebook/draft-js

Do you want to request a feature or report a bug?
This is a bug.

What is the current behavior?
When in composition mode (e.g. using a US - International or Korean keyboard) in a Draft editor, pressing tab moves focus out of the editor AFTER committing the in-progress composition. It looks like this:
鉁呪渽鉁呪渽
draft-js chrome macos - draft editor blurred by tab key

If the Draft editor loses focus for other reasons (e.g. JS calls .blur() on the editor element) the composition is erased instead of being committed. It looks like this:
鉂屸潓鉂屸潓
draft-js chrome macos - draft editor blurred by js blur
In this gif I am calling:

  setTimeout(() => {
    console.log("Blurring NOW", document.activeElement);
    document.activeElement.blur();
    console.log("Active element is now: ", document.activeElement);
  }, 5000);

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. You can use this jsfiddle to get started: https://jsfiddle.net/stopachka/m6z0xn4r/.
Reproduces in Chrome+macOS.
Does NOT reproduce in Firefox+macOS.

  1. On macOS, add "2-Set Korean" to your keyboards and switch to it
  2. Open this codesandbox
  3. Type into the input something that enters composition mode, e.g. "gksrmf"
  4. Wait a few seconds for the JS to call .blur() on the Draft editor
  5. The in-progress composition will be deleted (just as in the gif above)

What is the expected behavior?
The in-progress composition should remain (as it does in Firefox or when pressing tab).

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?
macOS Mojave (10.14.2)
Chrome Version 71.0.3578.98 (Official Build) (64-bit)
React 16.8.0
Immutable 4.0.0-rc.12
Draft.js 0.10.5

IME

Most helpful comment

1632

1274

This is such an outstanding issue. too bad we didn't find a solution up until now.

All 2 comments

1632

1274

This is such an outstanding issue. too bad we didn't find a solution up until now.

Thanks for reporting this issue @altano!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

darklightblue picture darklightblue  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

flarnie picture flarnie  路  3Comments

eessex picture eessex  路  3Comments

pklavins picture pklavins  路  3Comments