Setting text input value and then focusing input in JS can leave cursor outside of visible portion of input text
Categories
(Core :: Layout: Form Controls, enhancement)
Tracking
()
People
(Reporter: lucas.werkmeister, Unassigned)
Details
Attachments
(1 file)
|
77 bytes,
text/html
|
Details |
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0
Steps to reproduce:
- Have a text input of limited width on a page.
- Set its
valueto a string longer than can be displayed in the input. - Call
focus()on it.
The attached file serves as a demonstration.
Actual results:
The text input is focused, with the cursor at the end of the text, but the beginning of the text is shown – consequently, the cursor is not visible until the user either scrolls the text inside the input or moves the cursor. This can give the appearance that the input wasn’t focused at all.
Expected results:
The cursor should be visible, so that the focus can be seen.
This could be achieved by moving the focus inside the visible area or moving the visible area to cover the focus (i. e. scroll to the end of the text). Chromium and GNOME Web / Epiphany both do the latter.
Note that the HTML Living Standard specifies in § 4.10.5.4 Common input element APIs that setting the value moves the cursor to the end; it’s not clear to me that moving the cursor as part of the focus() operation would be allowed at all, though the focus updating steps in § 6.5.4 Processing model allow to “[a]pply any relevant platform-specific conventions”.
| Reporter | ||
Comment 1•6 years ago
|
||
This might be the same issue as bug 696743, I’m not sure – that bug’s description sounds similar but not enough that I’m confident to call it the same problem.
Comment 2•6 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Updated•3 years ago
|
Description
•