Closed Bug 1840700 Opened 11 months ago Closed 11 months ago

Bug 1815802 broke line break behaviour for CKEditor

Categories

(Core :: DOM: Selection, defect, P1)

Firefox 111
defect

Tracking

()

VERIFIED FIXED
116 Branch
Tracking Status
firefox-esr102 --- unaffected
firefox-esr115 116+ verified
firefox114 --- wontfix
firefox115 --- wontfix
firefox116 --- verified

People

(Reporter: soeren.hentzschel, Assigned: masayuki)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

The change in bug 1815802 broke the line break behaviour for CKEditor, one of the world's most popular WYISWYG editors. Please note: The issue does not always happen but very often. If it doesn't happen just reload the page and try again. For me it always happened with the second or third try at the latest.

STR scenario 1:

  1. Open https://ckeditor.com/ckeditor-5/demo/feature-rich/
  2. Remove the content, enter some content
  3. Press Shift + Enter to make a line break
  4. Enter more content

Actual:

The cursor stays in the first line after step 3, so you think that no line break was applied. But after step 4 the additional content is in a new line, so in fact the line break worked but it was not obvious to the user.

Expected:

The cursor is in a new line after step 3.

STR scenario 2:

  1. Open https://ckeditor.com/ckeditor-5/demo/feature-rich/
  2. Remove the content, enter some content
  3. Press Shift + Enter to make a line break
  4. Since you think that the line break didn't work repeat step 3
  5. Enter more content

Actual:

After step 3 the cursor is still in the first line (see scenario 1), after step 4 the cursor is in a new line. After step 5 an additional line break is between both lines of text.

Expected:

The cursor should be in the second line after step 3, a further line should be added after step 4, no jump after step 5 because the additional line was already added after step 4.

I also reported it to the developers of CKEditor:
https://github.com/ckeditor/ckeditor5/issues/14479

Flags: needinfo?(masayuki)

The latest selection API calls are at typing Shift + Enter:

I/SelectionAPI 21c527154a0 Selection::CollapseJS(aContainer=p.div[contenteditable="true"].div.div.div.div['b-demo-editor'].div.div.section.main.body.html.#document, aOffset=2)
D/SelectionAPI
#01: mozilla::dom::Selection::CollapseJS (M:\src\dom\base\Selection.cpp:2349)
#02: mozilla::dom::Selection_Binding::collapse (M:\fx64-dbg\dom\bindings\SelectionBinding.cpp:549)
#03: mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy,mozilla::dom::binding_detail::ThrowExceptions> (M:\src\dom\bindings\BindingUtils.cpp:3329)
#04: CallJSNative (M:\src\js\src\vm\Interpreter.cpp:486)
#05: js::InternalCallOrConstruct (M:\src\js\src\vm\Interpreter.cpp:580)
#06: js::Interpret (M:\src\js\src\vm\Interpreter.cpp:3395)
#07: js::RunScript (M:\src\js\src\vm\Interpreter.cpp:458)
#08: js::InternalCallOrConstruct (M:\src\js\src\vm\Interpreter.cpp:612)
I/SelectionAPI 21c527154a0 Selection::ExtendJS(aContainer=p.div[contenteditable="true"].div.div.div.div['b-demo-editor'].div.div.section.main.body.html.#document, aOffset=2)
D/SelectionAPI
#01: mozilla::dom::Selection::ExtendJS (M:\src\dom\base\Selection.cpp:2684)
#02: mozilla::dom::Selection_Binding::extend (M:\fx64-dbg\dom\bindings\SelectionBinding.cpp:751)
#03: mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy,mozilla::dom::binding_detail::ThrowExceptions> (M:\src\dom\bindings\BindingUtils.cpp:3329)
#04: CallJSNative (M:\src\js\src\vm\Interpreter.cpp:486)
#05: js::InternalCallOrConstruct (M:\src\js\src\vm\Interpreter.cpp:580)
#06: js::Interpret (M:\src\js\src\vm\Interpreter.cpp:3395)
#07: js::RunScript (M:\src\js\src\vm\Interpreter.cpp:458)
#08: js::InternalCallOrConstruct (M:\src\js\src\vm\Interpreter.cpp:612)
I/SelectionAPI 21c527154a0 Selection::AddRangeJS(aRange={ mStart=mEnd={ mParent=0000021C5289CB80 (p.div[contenteditable="true"].div.div.div.div['b-demo-editor'].div.div.section.main.body.html.#document, Length()=3), mRef=br.p.div[contenteditable="true"].div.div.div.div['b-demo-editor'].div.div.section.main.body.html.#document @ 0000021C528978B0 (br.p.div[contenteditable="true"].div.div.div.div['b-demo-editor'].div.div.section.main.body.html.#document), mOffset=2, mIsMutationObserved=true }, mIsGenerated=false, mCalledByJS=true, mIsDynamicRange=true })
D/SelectionAPI
#01: mozilla::dom::Selection::AddRangeJS (M:\src\dom\base\Selection.cpp:2146)
#02: mozilla::dom::Selection_Binding::addRange (M:\fx64-dbg\dom\bindings\SelectionBinding.cpp:355)
#03: mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy,mozilla::dom::binding_detail::ThrowExceptions> (M:\src\dom\bindings\BindingUtils.cpp:3329)
#04: CallJSNative (M:\src\js\src\vm\Interpreter.cpp:486)
#05: js::InternalCallOrConstruct (M:\src\js\src\vm\Interpreter.cpp:580)
#06: js::Interpret (M:\src\js\src\vm\Interpreter.cpp:3395)
#07: js::RunScript (M:\src\js\src\vm\Interpreter.cpp:458)
#08: js::InternalCallOrConstruct (M:\src\js\src\vm\Interpreter.cpp:612)
Flags: needinfo?(masayuki)
Assignee: nobody → masayuki
Severity: -- → S2
Status: NEW → ASSIGNED
Priority: -- → P1
OS: Unspecified → All
Hardware: Unspecified → All

Workaround for web apps is, call removeAllRanges() before calling addRange().

It always set to "start of next line" when new range was added. However,
after bug 1815802, it does nothing when adding range is one of its ranges.
Therefore, if interline position is set to "end of line" by our internal
code, like editor, getSelection().addRange(getSelection().getRangeAt(0))
keeps the last interline position.

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/4144104e69d6
Make `Selection::AddRangeAndSelectFramesAndNotifyListenersInternal()` update interline position even if it does nothing r=jjaschke
Status: ASSIGNED → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 116 Branch

The patch landed in nightly and beta is affected.
:masayuki, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox115 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(masayuki)

Thank you very much for the really fast fix!

Since Firefox 115 is already a RC, the bug exists since Firefox 111 and it doesn't seem that there are many similar reports if any at all I guess it's fine to WONTFIX this for the Firefox 115.0 release and let it ride the train to Firefox 116. But as Firefox 115 will be the new ESR and this bug can be very annoying when using CKEditor I suggest to consider this for Firefox ESR 115.1.

(In reply to Sören Hentzschel from comment #8)

Since Firefox 115 is already a RC, the bug exists since Firefox 111 and it doesn't seem that there are many similar reports if any at all I guess it's fine to WONTFIX this for the Firefox 115.0 release and let it ride the train to Firefox 116. But as Firefox 115 will be the new ESR and this bug can be very annoying when using CKEditor I suggest to consider this for Firefox ESR 115.1.

Thank you. Yeah, I completely agree with that.

Flags: needinfo?(masayuki)

Comment on attachment 9341439 [details]
Bug 1840700 - Make Selection::AddRangeAndSelectFramesAndNotifyListenersInternal() update interline position even if it does nothing r=jjaschke!

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: This is an annoying bug for users (caret is not painted at proper position), a new regression (from point of view of ESR) starting from 111 and reproducible with a major editing web application framework.
  • User impact if declined: While this bug is reproduced, typing text is inserted to different position (start of next line).
  • Fix Landed on Version: 116
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Only resetting "interline position" which was done before landing bug 1815802. That specifies the caret position (if selection is collapsed at <br>) whether end of previous line or start of new line.
Attachment #9341439 - Flags: approval-mozilla-esr115?
Flags: qe-verify+

Comment on attachment 9341439 [details]
Bug 1840700 - Make Selection::AddRangeAndSelectFramesAndNotifyListenersInternal() update interline position even if it does nothing r=jjaschke!

Approved for 115.1esr

Attachment #9341439 - Flags: approval-mozilla-esr115? → approval-mozilla-esr115+
QA Whiteboard: [qa-triaged]

I have reproduced the issue using Firefox 114.0.2 (20230619081400) and verified the fix using Firefox Nightly 116.0a1 (20230628153602) and Firefox 115.1.0esr (20230706135840) on MacOS 11.6, Ubuntu 20.04 and Windows 10.

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

Attachment

General

Created:
Updated:
Size: