Open Bug 1800523 Opened 3 years ago Updated 3 years ago

execCommand("delete") moves the caret before the current block element

Categories

(Core :: DOM: Editor, defect, P3)

Firefox 106
defect

Tracking

()

People

(Reporter: viktor.pyshnenko, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 2 obsolete files)

Attached file test.html (obsolete) —

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0

Steps to reproduce:

I tried to select the "bar" text node then delete it with the Delete command and then insert the 'X' character.

so the javascript goes like this:

document.designMode = 'on'
const sel = document.getSelection()
const p2 = document.querySelectorAll('p')[1]
sel.setBaseAndExtent(p2, 0, p2, 1) // select the "bar" text node
/* DOM before the commands execution
<body>
<p>foo</p>
<p>bar<span></span>baz</p>
</body>
*/

document.execCommand('Delete', false)
document.execCommand('insertText', false, 'X')

/* DOM after the commands execution
<body>
<p>foo</p>
X
<p><span></span>baz</p>
</body>
*/

Actual results:

The 'X' character is inserted before the second paragraph

Expected results:

The 'X' character should be inserted at the beginning of the second paragraph

Attached file test.js (obsolete) —
Attached file Incorrect behavior
Attachment #9303353 - Attachment is obsolete: true
Attachment #9303356 - Attachment is obsolete: true

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Editor' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Editor
Product: Firefox → Core

Masayuki, can you check for correctness and set the severity, please?

Flags: needinfo?(masayuki)

Oh, tricky case. Unfortunately, I've not refactored the selection handling in deletion code. So I'm not sure whether this can be fixed quickly.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Depends on: 1797247
Ever confirmed: true
Flags: needinfo?(masayuki)
OS: Unspecified → All
Priority: -- → P3
Hardware: Unspecified → All
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: