Select the whole string on focus in inputFields does not work every time
Categories
(Core :: DOM: UI Events & Focus Handling, defect, P5)
Tracking
()
People
(Reporter: fabio.gimmillaro, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: parity-chrome, Whiteboard: [h2review-noted])
Attachments
(1 file)
243 bytes,
text/html
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0
Steps to reproduce:
Added two input fields
<input value="zxcv"><input value="zxcv">
injected behavior through javascript:
for(let input of document.getElementsByTagName('input')) {
input.addEventListener('focusin', () => {
input.setSelectionRange(0, 4)
})
}
The mouse should always be on top of a character within the input field. Clicking on a different spot within the input field works as intended.
- Select first input field with the mouse // OK: SelectionRange is set properly
- Select second input field // OK
- Select first input field again // FAIL!
In my case it failed every time. If it shouldnt fail, go on by repeating step 2 and step 3.
Actual results:
On the third selection the selection range disapperead and the cursor appeared on the character I clicked on.
Expected results:
All 4 characters should be marked by the selection when first entering the input field.
Comment 1•4 years ago
|
||
I can reproduce the issue if clicked on text, not on empty area in input field.
It seems
when mousedown, the text selected as expected
and then mouseup, the selection is collapsed and put caret at mouse position.
This does not happen on Chrome.
Comment 2•4 years ago
|
||
Comment 3•4 years ago
|
||
(In reply to Alice0775 White from comment #1)
It seems
when mousedown, the text selected as expected
and then mouseup, the selection is collapsed and put caret at mouse position.
Exactly.
- https://searchfox.org/mozilla-central/rev/cbd110d718bc89a499d3f996af24532abbf6f8ea/layout/generic/nsFrame.cpp#4313,4322-4324,4327-4328
- https://searchfox.org/mozilla-central/rev/cbd110d718bc89a499d3f996af24532abbf6f8ea/layout/generic/nsFrame.cpp#4966,5052
- https://searchfox.org/mozilla-central/rev/cbd110d718bc89a499d3f996af24532abbf6f8ea/layout/generic/nsFrame.cpp#4913,4941
- https://searchfox.org/mozilla-central/rev/cbd110d718bc89a499d3f996af24532abbf6f8ea/layout/generic/nsFrameSelection.cpp#1094,1123
- https://searchfox.org/mozilla-central/rev/cbd110d718bc89a499d3f996af24532abbf6f8ea/layout/generic/nsFrameSelection.cpp#1223,1272
I think that when you click <input>
element first time, it causes creating TextEditor
instance after these steps. I mean that editor initialization process unexpectedly makes it work as expected.
Unfortunately, focusin
event must be fired during mousedown
event handling because ESM calls nsFocusManager::SetFocus()
. Therefore, I have no idea how to consider whether the selection change at mouseup
should be done or not without adding new flag into some object.
Updated•4 years ago
|
Comment 4•2 years ago
|
||
The bug has a release status flag that shows some version of Firefox is affected, thus it will be considered confirmed.
Updated•2 years ago
|
Description
•