Open Bug 1735102 Opened 3 years ago Updated 3 years ago

Can't use execCommand("insertText" ... on newly focused contenteditable DIV from `focus` event listener without changing selection explicitly

Categories

(Core :: DOM: Copy & Paste and Drag & Drop, defect, P3)

Firefox 93
defect

Tracking

()

People

(Reporter: will, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36

Steps to reproduce:

run the following fiddle: https://jsfiddle.net/apqv9g4z/
try and drag some text into the teal box

Actual results:

when you drag the text, nothing appears in the contenteditable DIV. You have to focus the div again for the text to appear in the box. (Comment out line 15 to remove this behavior)

Expected results:

When you drag the text in the DIV, the text appears. It works under chrome.

Component: Untriaged → DOM: Editor
Product: Firefox → Core
Severity: -- → S3
Status: UNCONFIRMED → NEW
Component: DOM: Editor → DOM: Copy & Paste and Drag & Drop
Ever confirmed: true
Keywords: parity-chrome

The reason of the failure is, when web app gets focus event, builtin editor of Gecko has not been re-initialized the selection for new focused editing host yet. Therefore, selection stays on the drag source node(s) at that time, and they are not editable, and finally, our HTML editor does nothing.

Indeed, we should fix the difference from the other browsers, but this is not so important because web apps should collapse selection into dropped point before calling execCommand("inserttext"). So I think that we don't need to fix so soon.

https://jsfiddle.net/d_toybox/w18p6ujr/ (see line 10 and 19).

I think that nsFocusManager should notify new/old focused editor of focus change directly before dispatching focus/blur events.

OS: Unspecified → All
Priority: -- → P3
Hardware: Unspecified → All
Summary: Can't use execCommand("insertText" ... on newly focused contenteditable DIV → Can't use execCommand("insertText" ... on newly focused contenteditable DIV from `focus` event listener without changing selection explicitly

(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #1)

The reason of the failure is, when web app gets focus event, builtin editor of Gecko has not been re-initialized the selection for new focused editing host yet. Therefore, selection stays on the drag source node(s) at that time, and they are not editable, and finally, our HTML editor does nothing.

Indeed, we should fix the difference from the other browsers, but this is not so important because web apps should collapse selection into dropped point before calling execCommand("inserttext"). So I think that we don't need to fix so soon.

https://jsfiddle.net/d_toybox/w18p6ujr/ (see line 10 and 19).

I think that nsFocusManager should notify new/old focused editor of focus change directly before dispatching focus/blur events.

thanks for providing the fix, this will do the trick

You need to log in before you can comment on or make changes to this bug.