execCommand("delete") moves the caret before the current block element
Categories
(Core :: DOM: Editor, defect, P3)
Tracking
()
People
(Reporter: viktor.pyshnenko, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(2 files, 2 obsolete files)
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
| Reporter | ||
Comment 1•3 years ago
|
||
| Reporter | ||
Comment 2•3 years ago
|
||
| Reporter | ||
Comment 3•3 years ago
|
||
Comment 4•3 years ago
|
||
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.
Comment 5•3 years ago
|
||
Masayuki, can you check for correctness and set the severity, please?
Comment 6•3 years ago
|
||
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.
Description
•