facebookarchive / draft-js

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

Bug: selecting a link entity and replacing it with a new text keeps the first character associated with the link #1932

Open alinalobast opened 5 years ago

alinalobast commented 5 years ago

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

What is the current behavior? When you create a link entity, then select it (via mouse or cmd+A) and replace it by typing a new text, first character of the new text is still associated with a link. If you delete a link with a backspace though, everything works as expected, so it only happens for selection without explicit removal.

Repro here https://codepen.io/anon/pen/MzyVNy:

  1. Type in a word
  2. Select the whole thing (cmd+A), click 'Add a link'
  3. Add a link, hit Confirm
  4. Select your text or highlight everything (cmd+A)
  5. Start typing a new text so that it replaces your link
  6. See the first character of your new text having an old link entity

What is the expected behavior? First character of the new text should not have an entity

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js? Affected version of Draft: 0.10.5. All previous versions of Draft do not remove entity on selection at all, entity is being applied to the new text. Trying in Chrome 70.0.3538.77 (64-bit)

JosieGittingTheHub commented 4 years ago

Having the same issue here.. Any news or solutions?

apsavin commented 4 years ago

Still an issue in Draft 0.11.7

zuffik commented 4 years ago

Any update on this? I'd like to keep selected entity when typing.