Cursor jumps to the start of input when changing input type
See original GitHub issue- [x ] The issue is present in the latest release.
- [ x] I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Cursor jumps to the start of input when changing input type
Expected Behavior 🤔
Cursor preserves its position when changing input type
Steps to Reproduce 🕹
Steps:
- Create textfield with password input type and visibility toggler like this: https://material-ui.com/components/text-fields/#input-adornments
- Input some text
- Click password visibility icon button
- Cursor jumps to the start of input
Context 🔦
Your Environment 🌎
Version 90.0.4430.85 (Official Build) (x86_64)
`npx @material-ui/envinfo`
Don't forget to mention which browser you used.
Output from `npx @material-ui/envinfo` goes here.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Cursor jumps to the start of input when changing input type
Input some text. Click password visibility icon button. Cursor jumps to the start of input.
Read more >Why does cursor move to start of input field when value is ...
First, i do not understand why my input field is setting cursor to start of the input field even though i am changing...
Read more >Possible fix of cursor jumping at the end of the input field
A possible fix is to save and restore the position of the cursor (aka caret) while updating the input field with something like...
Read more >Updating input fields without losing the cursor position
When the input field updates as you're typing, the cursor jumps to the end of the input. This is a side-effect of not...
Read more >The Curious Case of Cursor Jumping - Mutually Human
Programmatically changing the text field value resets its cursor position · Single line text fields (via <input type=text /> resets the cursor to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found a workaround to this problem by calling
preventDefault()
on theonMouseUp
event as well.https://codesandbox.io/s/admiring-bash-htted?file=/pages/index.js
I wasn’t able to track down this bug but I don’t think it’s React fault since it works properly on CRA.
Hope it helps
I tried this same strategy on a Vue project. It works beautifully. Much appreciated.