Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor position resetting with a conditional prefix #742

Closed
2 tasks done
Treycos opened this issue Mar 8, 2023 · 5 comments · Fixed by #756
Closed
2 tasks done

Cursor position resetting with a conditional prefix #742

Treycos opened this issue Mar 8, 2023 · 5 comments · Fixed by #756

Comments

@Treycos
Copy link

Treycos commented Mar 8, 2023

When using NumericFormat with a conditional prefix, the cursor position is reset to the left of the input after the prefix changes

In v4, it maintained the usual behavior, the cursor doesn't move when a prefix is added midway through typing

Code Sandbox: https://codesandbox.io/s/react-number-format-forked-654ycv?file=/src/index.js

To reproduce:

  • Clear the left input

  • Type a number

  • Cursor is reset at the end

  • Clear the right input

  • Type a number

  • Cursor is where it should be

  • Chrome

  • Firefox

@sormpe
Copy link

sormpe commented Mar 13, 2023

I think #725 is related

@s-yadav
Copy link
Owner

s-yadav commented May 14, 2023

This is fixed on v5.2.0

@akhmadullin
Copy link

Hi

c0157ea broke cursor position in another case

I have phone input. When input is focused and empty - short mask (+7 () is shown
short mask

when input is not empty - full-format mask (+7 (###) ###-####) is shown
long mask

c0157ea affects copy+paste process

Previously, before c0157ea, after applying copy+paste cursor was after last inserted symbol in input

prev.mov

Now (commit c0157ea) after applying copy+paste cursor is stayed on the same place, where is was before pasting

now.mov

Is it possible to fix this issue?

@s-yadav
Copy link
Owner

s-yadav commented Jun 27, 2023

Sure @akhmadullin, will take a look. Can you create a sandbox with this bug, it will help debugging.

@akhmadullin
Copy link

@s-yadav, ok

I created separate issue - #772, where I described problem and provided links to sandbox with examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants