JedWatson / JedWatson/react-select

when using onInputChange/inputValue, cursor is positioned to the end of the input field on each keystroke

Open
#5,942 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

issue/bug-unconfirmed
Dominant language
TypeScript
Stars
28k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

This is on react-select v5.8.0.

My onInputChange handler is storing the text in a local var, inputValue is being provided as prop. If you position the cursor inside the input text, and type a character the cursor jumps to the end.

I am doing this, because in certain situations I want to programmatically modify the input text.

One solution would be for the control to remember the text cursor location when updating the text from the prop and restore afterwards.

Another solution, which is not complete but would cover a lot of it, would be simply to do nothing if inputValue is the same as the current text in the input element.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in react-select v5.8.0 using a controlled inputValue and onInputChange handler, with the cursor placed inside existing text. Trace the input update path and verify that typing preserves the cursor position while programmatic input changes still take effect.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.