I'm trying out the basic implementation of DraftJS with Rich styles. When I select a word and apply a style to it (like bold/italics), it applies it. But it loses the selected text (the word is not selected anymore). If I click on the editor region, it selects it again.
I don't see a similar workflow when I try the examples. So I'm pretty sure I'm missing something, but I don't know what. Is there something I should do to retain the selected content?
Are you applying a style with a mouse click that's changing focus
after? You could try prevent default in the click handler where you apply
the style.
On Thursday, April 7, 2016, Swaathi Kakarla [email protected]
wrote:
I'm trying out the basic implementation of DraftJS with Rich styles. When
I select a word and apply a style to it (like bold/italics), it applies it.
But it loses the selected text (the word is not selected anymore). If I
click on the editor region, it selects it again.I don't see a similar workflow when I try the examples. So I'm pretty sure
I'm missing something, but I don't know what. Is there something I should
do to retain the selected content?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/facebook/draft-js/issues/275
Nope. I'm using a onMouseDown on a span element to apply the style.
I suggest using preventDefault on the mousedown event.
Thanks so much! This cleared it up right away. :+1: :smile:
The preventdefault fix doesn't work anymore in 0.11
Most helpful comment
I suggest using
preventDefaulton the mousedown event.