react-mentions icon indicating copy to clipboard operation
react-mentions copied to clipboard

OnChange return different value for event.target.value if it was triggered by a cut(CTRL+X)

Open lucasMarioza opened this issue 4 years ago • 4 comments

Steps to reproduce:

  1. Add a mention to your field
  2. Type anything else
  3. event.target.value for your onChange will be the raw text, before parsing mentions
  4. now select any text that is not part of a mention
  5. press CTRL+X
  6. 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

lucasMarioza avatar Nov 27 '20 17:11 lucasMarioza

Having the same issue! It will be really helpful to get this fixed! @lucasMarioza did you find any workaround?

fernandacoto avatar Feb 24 '21 17:02 fernandacoto

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.

fabianchacon avatar Feb 24 '21 17:02 fabianchacon

@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

lucasMarioza avatar Feb 24 '21 20:02 lucasMarioza

Cntrl+X breaking highlited design input value becomes plain text

bayaroch avatar May 20 '21 07:05 bayaroch