Open Bug 1611761 Opened 4 years ago Updated 2 years ago

Select the whole string on focus in inputFields does not work every time

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P5)

72 Branch
Desktop
All
defect

Tracking

()

Tracking Status
firefox-esr68 --- wontfix
firefox72 --- wontfix
firefox73 --- affected
firefox74 --- affected

People

(Reporter: fabio.gimmillaro, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome, Whiteboard: [h2review-noted])

Attachments

(1 file)

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.

  1. Select first input field with the mouse // OK: SelectionRange is set properly
  2. Select second input field // OK
  3. 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.

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.

Component: Untriaged → DOM: UI Events & Focus Handling
Keywords: parity-chrome
OS: Unspecified → All
Product: Firefox → Core
Hardware: Unspecified → Desktop
Attached file reporter's html

(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.

  1. https://searchfox.org/mozilla-central/rev/cbd110d718bc89a499d3f996af24532abbf6f8ea/layout/generic/nsFrame.cpp#4313,4322-4324,4327-4328
  2. https://searchfox.org/mozilla-central/rev/cbd110d718bc89a499d3f996af24532abbf6f8ea/layout/generic/nsFrame.cpp#4966,5052
  3. https://searchfox.org/mozilla-central/rev/cbd110d718bc89a499d3f996af24532abbf6f8ea/layout/generic/nsFrame.cpp#4913,4941
  4. https://searchfox.org/mozilla-central/rev/cbd110d718bc89a499d3f996af24532abbf6f8ea/layout/generic/nsFrameSelection.cpp#1094,1123
  5. 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.

Priority: -- → P5
Whiteboard: [h2review-noted]

The bug has a release status flag that shows some version of Firefox is affected, thus it will be considered confirmed.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: