facebookarchive / draft-js

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

Only one custom inline style is persisted at a time when text is not selected #1690

Open soniapatel opened 6 years ago

soniapatel commented 6 years ago

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

What is the current behavior? Only one custom inline style is persisted at a time when text is not selected.

**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: After selecting text, any custom inline style can be applied from font style, font size, text color or background color. With selecting text if more than one custom inline style are selected, it resets the previously selected style to the default value. We are using toggleCustomInlineStyle from the draft-utils. 200w_d

What is the expected behavior? All the custom inline styles should be persisted and applied to the text that the user types in the editor.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js? "draft-js": "^0.10.4" Mac: Chrome, Firefox. It did not work in any version of draft js.

thibaudcolas commented 6 years ago

Hey @soniapatel, it's very hard to tell from the super small GIF but it looks like you're using https://github.com/jpuri/react-draft-wysiwyg.

I think this is most likely an issue with that particular project, not Draft.js. On the Draft.js-only https://draftjs.org/ editor, you can correctly select text and then apply multiple inline styles.

kamenminkovcom commented 5 years ago

@thibaudcolas check this one. The behavior is the same as @soniapatel describes. I have also created an issue and think that the issues are pretty much the same so feel free to close it.

thibaudcolas commented 5 years ago

Yes, this does sound like the same issue. This is working as I would expect in my own editor and on https://draftjs.org/, so yep I wouldn't be surprised if this was just a matter of using onMouseDown instead of onClick as you describe so the selection isn't reset in-between clicks.