<input> should scroll its text to the start on blur/lose focus
Categories
(Core :: Layout: Form Controls, enhancement)
Tracking
()
People
(Reporter: dtrebbien, Unassigned)
Details
Comment 1•12 years ago
|
||
![]() |
||
Comment 2•12 years ago
|
||
Reporter | ||
Comment 3•12 years ago
|
||
Comment 4•12 years ago
|
||
Reporter | ||
Comment 5•12 years ago
|
||
Comment 6•12 years ago
|
||
This is still causing issues today (8 years later):
https://stackoverflow.com/questions/67055218/set-input-caret-position-on-blur-in-safari-without-refocusing-input
Comment 8•4 years ago
|
||
I think I agree with comment 2... I'm not sure why this is particularly desirable, and why would it be inconsistent with textarea, where other browsers don't auto-scroll on blur?
(In reply to cetin from comment #7)
Why do you need to use setSelectionRange
? input.scrollLeft = 0
achieves the same and shouldn't have non-layout side-effects I'd think.
Updated•3 years ago
|
Comment 9•3 years ago
|
||
I've just run into this behaviour, and I agree both that the current Firefox behaviour is inconsistent and leaving the end of the text showing rather than the beginning isn't the most sensible option.
Showing the beginning makes more sense
I think I agree with comment 2... I'm not sure why this is particularly desirable, and why would it be inconsistent with textarea, where other browsers don't auto-scroll on blur?
It's desirable because (assuming LTR language) we read from left to right. Consider a long filename:
"Company Report containing extra revisions for internal release v2"
Chrome will show us:
"Company Report"
Firefox will show:
"release v2"
Which leads the user to think either "I wonder what release of the company report this is (perhaps I should double check) vs "Oh it's release v2 of something, I wonder what?"
In general, the most valuable information in a field is likely to be on the left, because that's how humans communicate. We tend to transmit the most significant bits of information first. "Run away from the bears coming over the hill" vs "over the hill are coming bears which we should run away from"; survival favours those who hear the first sentence over the second.
We go from specific, to narrow, roughly speaking, and it is usually impossible to infer the context from looking at the end of a sentence.
Firefox's Inconsistent Behaviour
The current behaviour is also internally inconsistent.
Ellipsis in english are a visual signal that says "there is more content here than I can display".
Here's the logic in Chrome:
no ellipsis = "all content displayed here"
ellipsis = "this text continues to the right but I can't display it all in this space."
In Firefox
no ellipsis = "all content displayed here" OR it could mean "there is more content than I can display, and the last time you edited this field the cursor was in a position so that the content I can't display is to the left."
ellipsis = "there is more content here than I can display, and last time you edited this field the cursor was in a position such that the content I can't display is to the right"
Describing Chrome's behaviour is simpler, and it less confusing to the user.
In Firefox, the absence of an ellipsis doesn't tell us anything unless we remember the cursor position within the field.
The best way to resolve the ambiguity is to "scroll" the field to the left (actually, just show the beginning of the field when not focused).
Comment 10•1 year ago
|
||
In addition to that, setting text-overflow: ellipsis
will also not work when not scrolled to the start of the text
Description
•