react-mentions
react-mentions copied to clipboard
OnChange return different value for event.target.value if it was triggered by a cut(CTRL+X)
Steps to reproduce:
- Add a mention to your field
- Type anything else
-
event.target.value
for your onChange will be the raw text, before parsing mentions - now select any text that is not part of a mention
- press CTRL+X
-
event.target.value
for your onChange will be the plain text, after parsing mentions
Expected behaviour: In both cases, it should return the raw text
Workaround:
never use event.target.value
, use the other parameters sent: newValue
and newPlainTextValue
Possible Solution I believe the actual solution is to change this line to
const eventMock = { target: { ...event.target, value: newValue } }
but I have not checked where it would impact
Having the same issue! It will be really helpful to get this fixed! @lucasMarioza did you find any workaround?
The same here, I mean it is not very common that a user can will cut the text, but we have users complaining about we are losing the mention reference because of this bug, thanks in advance for any update.
@fernandacoto @fabianchacon the onChange will receive the following values event, newValue, newPlainTextValue, mentions
. So, instead of using event.target.value
as the expected, you can use newValue
. I believe that should fix it
Cntrl+X breaking highlited design input value becomes plain text