Closed akhmadullin closed 1 year ago
@akhmadullin looks like you have event.preventDefault()
added on paste event which hampers with selection. Earlier there used to be double rendering issue, due to side-effect of which even.preventDefault was not impacting the caret position. But that being fixed now event.preventDefault coming into picture.
Just remove that and it should work. Here's an updated sandbox. https://codesandbox.io/p/github/akhmadullin/rnf-v5.2.2-dynamic-mask-copy-paste-broken-demo/csb-dfjqf5/draft/strange-rgb?file=/src/phone-input.tsx:39,17
@s-yadav, yes, it works
thanks for help
Describe the issue and the actual behavior
c0157ea broke cursor position during copy+paste into input with dynamic mask
I have phone input. When input is focused and empty - short mask (
+7 (
) is shownwhen input is not empty - full-format mask (
+7 (###) ###-####
) is shownc0157ea affects copy+paste process
Previously, before c0157ea, after applying copy+paste cursor was after last inserted symbol in input
https://github.com/s-yadav/react-number-format/assets/37641303/4ed45467-cdeb-4444-8229-1bf77a78be01
Now (commit c0157ea) after applying copy+paste cursor is stayed on the same place, where is was before pasting
https://github.com/s-yadav/react-number-format/assets/37641303/22cf7a36-1171-43ca-a0e0-503b439d8a56
Describe the expected behavior
Expected behavior - after pasting cursor is moved to the end of the inserted text, as it was before c0157ea
https://github.com/s-yadav/react-number-format/assets/37641303/4ed45467-cdeb-4444-8229-1bf77a78be01
Provide a CodeSandbox link illustrating the issue
Demo for v5.1.4 - after copy+paste cursor is moving to the end of text
Demo for v5.2.2 - after copy+paste cursor is staying at the same position, where it was before pasting
Provide steps to reproduce this issue
Please check the browsers where the issue is seen
Solution
Is it possible to fix this issue?