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

Too many bugs in composition mode #2718

Open
szrenwei opened this issue Nov 19, 2020 · 8 comments
Open

Too many bugs in composition mode #2718

szrenwei opened this issue Nov 19, 2020 · 8 comments

Comments

@szrenwei
Copy link

szrenwei commented Nov 19, 2020

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

bug

What is the current behavior?

  1. Input some chars use IME, then command + z to undo the chars, it will not work
  2. Input two line text, select them all, use IME to input some chars, the second line would not be removed

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/gmertk/e61z7nfa/.

Just go to the official site to try: https://draftjs.org/

What is the expected behavior?

  1. undo should work when input use IME
  2. use IME should replace all selected lines

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

version >= 0.11.0 all have these problems, I notice that you have changed the composition handler, that is the cause of these bugs.

like this: https://github.com/facebook/draft-js/blob/master/src/component/handlers/composition/DraftEditorCompositionHandler.js#L256, the author must be
drunk when he write the code, EditorState.push has push the same contentState, this line of code just useless.

@thibaudcolas
Copy link
Contributor

Testing this briefly, it looks like it’s the first change to the editor that can’t be un-done:

ime-undo

I couldn’t reproduce the issue with replacing text, do you have more detailed steps @szrenwei?

@szrenwei
Copy link
Author

@thibaudcolas

  1. In fact, all your input use IME can't be undo, you can undo because you start a new block. ( the content add by IME just not been add to undo stack )

  2. As blew, select all text and try to replace:
    Nov-20-2020 10-47-03

@thibaudcolas
Copy link
Contributor

Thank you, that seems pretty clear-cut. Trying this again, I also managed to get the editor to crash (and the whole page, I imagine the demo doesn’t have any error handling).

ime-crash

@Marckon
Copy link

Marckon commented Dec 3, 2020

see this pomelovico/keep#30

@avatar0527
Copy link

see this pomelovico/keep#30

How/where would I implement this to get it to work? I'm still fairly new/learning but I feel like this might be just what I need!

@Marckon
Copy link

Marckon commented Jan 6, 2021

see this pomelovico/keep#30

How/where would I implement this to get it to work? I'm still fairly new/learning but I feel like this might be just what I need!

You just need to listen to comositionstart event when your editor mounted (like componentDidMount)

@avatar0527
Copy link

see this pomelovico/keep#30

How/where would I implement this to get it to work? I'm still fairly new/learning but I feel like this might be just what I need!

You just need to listen to comositionstart event when your editor mounted (like componentDidMount)

Thank you!

@psybor
Copy link

psybor commented Oct 27, 2022

#3177

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants