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

Input cursor position changes to end in SearchInput when controlled usage #797

Closed
light049 opened this issue Aug 29, 2023 · 5 comments · Fixed by #800
Closed

Input cursor position changes to end in SearchInput when controlled usage #797

light049 opened this issue Aug 29, 2023 · 5 comments · Fixed by #800
Labels
🐛 bug Something isn't working 👷 refactor (improvement) Improvements in the code base

Comments

@light049
Copy link
Contributor

light049 commented Aug 29, 2023

Could be reproduced at Keyword search section in demo site.

  1. Input some text
  2. Change input cursor to the start position of input
  3. Input text
  4. The cursor would move to end of input when 1st character is typed
@cheton
Copy link
Member

cheton commented Aug 31, 2023

@cheton cheton added the 👷 refactor (improvement) Improvements in the code base label Aug 31, 2023
@light049
Copy link
Contributor Author

light049 commented Aug 31, 2023

  1. Preserve and restore the cursor position, as shown in the example: https://codesandbox.io/s/boring-dirac-utq82?file=/src/App.tsx

In the codesandbox, I could not reproduce the issue after removing code about 'selection'

image

@cheton
Copy link
Member

cheton commented Aug 31, 2023

Reference:
https://egghead.io/lessons/react-preserve-cursor-position-when-filtering-out-characters-from-a-react-input

@cheton
Copy link
Member

cheton commented Aug 31, 2023

  1. Preserve and restore the cursor position, as shown in the example: https://codesandbox.io/s/boring-dirac-utq82?file=/src/App.tsx

In the codesandbox, I could not reproduce the issue after removing code about 'selection'

You have to press Space key to make string replacement work in this CodeSandbox example.

@light049
Copy link
Contributor Author

light049 commented Aug 31, 2023

But in this issue, there has no value modification in SearchInput, and it still has this behavior.
So, it might be separated into 2 parts to resolve:

  • fix SearchInput for input cursor jumping to end
  • enhance to help keep cursor position in input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 👷 refactor (improvement) Improvements in the code base
Projects
None yet
2 participants