Closed Bug 1360388 Opened 7 years ago Closed 3 years ago

"selectionchange" only fires once when entering text at end of textarea

Categories

(Core :: DOM: Selection, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1713334

People

(Reporter: jchen, Unassigned)

References

(Depends on 1 open bug)

Details

Attachments

(1 file)

Attached file Testcase
Using the testcase in Nightly, the "selectionchange" count only increases _once_ when inputting text at the end (and only at the end) of the <textarea> field.
Perhaps, this occurs when selection is collapsed at start of the trailing <br> element. I think that editor should collapse Selection at end of the end of the text node. (So, this might be an editor's bug.)

So 3 years have passed and selectionchange stopped working for Textarea/Input tags in Firefox completely? How are we suppose to track caret position without crazy hacks?

It works in Chrome, except it doesn't fire when you delete chars, only move caret around or enter.

(In reply to alexander from comment #3)

So 3 years have passed and selectionchange stopped working for Textarea/Input tags in Firefox completely? How are we suppose to track caret position without crazy hacks?

Although Masayuki comments this root cause by comment #1, Gecko sets selection position to last <br> element by TextEditor::EnsureCaretNotAtEndOfTextNode at force if inserted text is last. selectionchange is dispatched when selection position (node and offset) is changed. Unfortunately, even if text node before <br> element is changed, selected node and offset value is still same value. So selectionchange won't be dispatched.

So to fix this, we need another hack for <textarea> or change this design that we don't set selection to <br> element.

The repro stopped working on Chrome. Modifying line 11 to document.addEventListener("selectionchange") makes it work but then it stops working on Firefox. I guess there was a behavior change in selectionchange.

Filed Bug 1648944.

Fixed in:

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: