Closed Bug 1747008 Opened 3 years ago Closed 3 years ago

Page jumps at the top of editor after pasting text while using WikEd on wikipedia

Categories

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

Firefox 95
defect

Tracking

()

VERIFIED FIXED
97 Branch
Tracking Status
firefox-esr91 --- unaffected
firefox95 --- wontfix
firefox96 --- wontfix
firefox97 --- verified

People

(Reporter: ksenia, Assigned: masayuki)

References

(Regression, )

Details

(Keywords: regression)

Attachments

(2 files)

Attached file 94036.html

We've got a report in https://github.com/webcompat/web-bugs/issues/94036 about a problem with pasting text into WikEd editor while editing articles on Wikipedia. After pasting text, the cursor in contenteditable area gets moved to its starting point. The problem is severe on pages with a lot of content as it takes time to scroll back to the pasted text.

The editor is wrapping pasted text with two <span> elements with execCommand("insertHtml"). In Firefox the second <span> is missing after insertion, but the editor is relying on it to be in the DOM for further steps.

I've created a reduced test case to demonstrate the behaviour (for simplicity, only clicking inside contenteditable area is enough).

STR:

  1. Load the attached testcase and click inside contenteditable area
  2. Observe the message below

Expected:
"span with id wikEdScrollAfter is present"
Actual:
"span with id wikEdScrollAfter is missing"

This appears to be regressed by https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=a67baeba9a658f8650657389f38aa9bc7e2eef07&tochange=f895a0b6c0e3748e11381173b3cd32a7bb8c60dd

Hi Masayuki, could you please look into this?

Flags: needinfo?(masayuki)

Set release status flags based on info from the regressing bug 1730429

I see, we shouldn't delete empty inline elements if they are inserted intentionally.

Assignee: nobody → masayuki
Severity: -- → S3
Status: NEW → ASSIGNED
Flags: needinfo?(masayuki)
OS: Unspecified → All
Priority: -- → P3
Hardware: Unspecified → All

I checked what is different from Chrome quickly. The main difference for this bug is, Chrome collapse selection to the end of last text node of inserted HTML fragment. And if there is no text nodes in inserted HTML fragment, Chrome keeps caret at end of split text node before insertion point.

Following this behavior can fix this bug, but I'm really feel it's odd behavior. Perhaps, collapsing selection to after the inserted HTML fragment must be better to match with users' expectation...

Starting from bug 1730429, we strip empty inline elements at caret for
compatibility with Blink/WebKit. However, we should not do it for the elements
which are intentionally inserted (from inserthtml command, paste and DnD).

All the cases are handled by HTMLEditor::HTMLWithContextInserter so that
it should prevent the new clean up with TopLevelEditSubActionData.

Note that inserthtml command handling of Blink is really odd. It inserts
the empty inline elements of the adding testcases into different place so that
Chrome does not pass the new tests. However, it does not make sense and I
believe that it's out of scope of this bug.

Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/52f631e145e8 Make `HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal` stop stripping empty inline elements if they may be inserted intentionally r=m_kato
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/32283 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch
Upstream PR merged by moz-wptsync-bot

I was able to reproduce the issue on Win10 using build 96.0a1 (20211128092809) an steps from description.
Verified as fixed on Win10 / Mac 10.13 / Ubuntu 20.4 using build 97.0b5 (20220118185733).

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: