Open Bug 1267006 Opened 8 years ago Updated 2 years ago

setRangeText doesn't preserve selection after Undo

Categories

(Core :: DOM: Selection, defect)

45 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: sergroj, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID: 20160407164938

Steps to reproduce:

Open any page with an editable <textarea> or text <input> element. Write some text in it if there is none. Select anything (say, a word) in that element.
Write document.activeElement.setRangeText("HELLO WORLD") in the F12 console.
Press Ctrl+Z.


Actual results:

Change undone, but selection isn't preserved: whole text gets selected.


Expected results:

Text that was selected before the operation should be selected.
This is important for various forums where you need to insert BB codes, because there's currently no known way to insert text into a text area that's undo-friendly in the described sense.
Component: Untriaged → Selection
Product: Firefox → Core
It seems that setRangeText erases the entire history now.

Name 	Firefox
Version 	60.0b1
Build ID 	20180302190033
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.