Unable to delete selected text in a contenteditable <html>
Categories
(Core :: DOM: Editor, defect, P5)
Tracking
()
Tracking | Status | |
---|---|---|
firefox83 | --- | verified |
People
(Reporter: glob, Assigned: masayuki)
References
Details
Attachments
(1 file)
Steps to reproduce:
- Navigate to
data:text/html,<html contenteditable>
(this is a common "turn your browser into a notepad" hack) - Enter some text into the page
- Select all
- Press delete, or start typing to replace the selected text
Expected outcome:
- selected text is deleted
Actual outcome:
- selected text is not deleted
8:08.66 INFO: Last good revision: 0f723de1af731f06b09e3c1d94f6193f0ee97705
8:08.66 INFO: First bad revision: a75148ad144d87c836977c4de3e8c9d93197223a
8:08.66 INFO: Pushlog:
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=0f723de1af731f06b09e3c1d94f6193f0ee97705&tochange=a75148ad144d87c836977c4de3e8c9d93197223a
I suspect this was caused by Bug 1663797.
Assignee | ||
Comment 1•5 years ago
|
||
Thank you for the bug report!
Did you find this regression somewhere broken? I meant that I'd like to know whether there is or not a broken web apps in the wild.
Assignee | ||
Updated•5 years ago
|
Yes - I use data:text/html,<html contenteditable>
as a temporary notepad, useful to have as a pinned tab.
https://www.wired.com/2013/02/turn-your-browser-into-a-notepad-with-a-single-line-of-html5/
https://www.pcworld.com/article/2360940/turn-any-browser-tab-into-a-basic-text-editor.html
https://www.makeuseof.com/tag/use-browser-notepad/
and so on
Assignee | ||
Comment 3•5 years ago
|
||
(In reply to :glob 🎈 from comment #2)
Yes - I use
data:text/html,<html contenteditable>
as a temporary notepad, useful to have as a pinned tab.https://www.wired.com/2013/02/turn-your-browser-into-a-notepad-with-a-single-line-of-html5/
https://www.pcworld.com/article/2360940/turn-any-browser-tab-into-a-basic-text-editor.html
https://www.makeuseof.com/tag/use-browser-notepad/
and so on
Thank you. So, sounds like that some users may use it for simple case, but existing web apps are not broken especially in major web apps.
Assignee | ||
Comment 4•5 years ago
|
||
The regression range must be wrong. I can reproduce this on 81.0.2...
A workaround is to use data:text/html,<body contenteditable>
instead.
Assignee | ||
Comment 6•5 years ago
|
||
I see this bug on Firefox 52 (shipped in Nov, 2016). So, this is not at least recent regression.
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #6)
I see this bug on Firefox 52 (shipped in Nov, 2016). So, this is not at least recent regression.
Sorry, but this isn't correct - I have been using this feature for years, and it absolutely works in 81.0.2.
Assignee | ||
Comment 8•5 years ago
|
||
Due to this line, selection is collapsed to start of <body>
element when "Select all" selects all children of <html>
.
https://searchfox.org/mozilla-central/rev/9c72508fcf2bba709a5b5b9eae9da35e0c707baa/editor/libeditor/HTMLEditSubActionHandler.cpp#14305
But it's really hard to shrink the selection ranges into <body>
element without performance regression...
Assignee | ||
Comment 9•5 years ago
|
||
(In reply to :glob 🎈 from comment #7)
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #6)
I see this bug on Firefox 52 (shipped in Nov, 2016). So, this is not at least recent regression.
Sorry, but this isn't correct - I have been using this feature for years, and it absolutely works in 81.0.2.
Do you really use "Select all" (as you reported)? When I do it with Ctrl-A
on Windows, the selection range starts from start of <html>
and ends by end of it. I.e., wraps the <body>
element (and <head>
element) in this case. Therefore, at the very first check before deletion, selection is collapsed to start of <body>
, and Delete
deletes first content, but Backspace
does nothing.
Reporter | ||
Comment 10•5 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #9)
Do you really use "Select all" (as you reported)?
Yes.
I'm on macOS, could this be platform specific?
Assignee | ||
Comment 11•5 years ago
|
||
(In reply to :glob 🎈 from comment #10)
I'm on macOS, could this be platform specific?
No, it shouldn't. And I see exactly same symptom on macOS too. Backspace
(labeled "delete" on Mac) deletes nothing and collapse selection to start of the <body>
, Delete
(called by "forward delete" on Mac) deletes first character in the <body>
.
Assignee | ||
Comment 12•5 years ago
|
||
Okay, I find a quick fix. We should restrict "Select all" command handler selects all children of <body>
element.
Assignee | ||
Comment 13•5 years ago
|
||
In strictly speaking, we should shrink selection ranges at very first time
of edit action handling. However, we support multiple selection ranges and
it makes the check cost really expensive, and the code would be really
complicated since ranges cannot be overlapped. I.e., changing one range
could affect some of the others.
Therefore, this patch changes HTMLEditor::SelectAllInternal()
instead.
If computed selection root is an ancestor of <body>
element in HTML document,
it use the <body>
element instead.
Note that, in HTML document, there should be only one <body>
element and
only its content should be editable at least for now. (Note that in XHTML
document, no <body>
is allowed, multiple <body>
elements allowed.)
Comment 14•5 years ago
|
||
Comment 15•5 years ago
|
||
bugherder |
Updated•5 years ago
|
Comment 18•5 years ago
|
||
Reproduced the issue using Firefox 83.0a1 (20201014214248) on Windows 10x64 and macOS 10.12 by using the Select All context menu option.
The issue is verified fixed with Firefox 83.0b10 (20201108174701) on Windows 10x64, macOS 10.12 and Ubuntu 18.04.
Description
•