Open Bug 1267006 Opened 6 years ago Updated 4 years ago

setRangeText doesn't preserve selection after Undo


(Core :: DOM: Selection, defect)

45 Branch
Not set





(Reporter: sergroj, Unassigned)


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
You need to log in before you can comment on or make changes to this bug.