Set text cursor to the end of the input on focus?
See original GitHub issuethis.editor.focus()
sets the cursor at the beginning of the input, what is the preffered way of setting it at the end?
(Sorry if this has been answered before, searched the issues for “focus” and couldn’t seem to find any related issues.)
I’m on Mac/Chrome 57.0.2987.133.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Use JavaScript to place cursor at end of text in text input element
For the cursor to be move to the end, the input has to have focus first, then when the value is changed it...
Read more >Put cursor at the end of an input - HTML DOM
Put cursor at the end of an input. Assume that we have a text field representing the full name of an user. There...
Read more >How to place cursor position at end of text in text input field ...
At first, we are going to create a text input box where some value will be given and a button to place the...
Read more >Move cursor to the end of input [JavaScript] - Alvaro Trigo
You can move the cursor to the end of an input or a textarea by using `selectionStart` and `selectionEnd` properties of input elements...
Read more >Move Cursor to End of Input - CSS-Tricks
Where el is a reference to an input or textarea. function moveCursorToEnd(el) { if (typeof el.selectionStart == "number") { el.
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
If @brijeshb42 solution doesn’t work, take a look at
editor.focus()
code. I had to change @brijeshb42 solution to useforceSelection
instead. Full code here:Draftjs has moveSelectionToEnd(e: EditorState) function. So to move focus to end, you just need write this small piece of code: