Closed Bug 1840856 Opened 2 years ago Closed 2 years ago

Linefeed seems to be not working correctly in contenteditable

Categories

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

defect

Tracking

()

RESOLVED FIXED
120 Branch
Tracking Status
firefox120 --- fixed

People

(Reporter: jjaschke, Assigned: jjaschke)

References

Details

Attachments

(2 files, 1 obsolete file)

This bug is part of fixing contenteditable for interop-2023.

Currently, a contenteditable with preformatted whitespace rules (pressing [Enter] should insert a \n, not a <br>) is showing wrong behaviour (a <br> is inserted instead of \n).

This condition seems to be incorrect. As a result, this condition evaluates to false and the code that inserts a line feed (and an additional line break if necessary) is never called.

This patch is related to Bug 1840822, which fixes some issues
regarding additional invisible linebreaks needed at the end of
contenteditables.
This patch in particular fixes the case where the user
presses enter at the end of a pre-formatted
contenteditable, e.g.:

<span contenteditable style="display:block;white-space:pre-line">[]</span>

Prior to this patch, only one <br> was added,
the invisible padding linebreak was missing.
With this patch applied, the behaviour should be as expected:

<span contenteditable style="display:block;white-space:pre-line">\n<br></span>

Depends on D185935

Chrome inserts default paragraph separator even if the editing host cannot have
<div> nor <p> in the editing host.

I think that it's fine if a paragraph is at the insertion point and split it
because the web apps may create the invalid structure and the other browsers
works as so.

On the other hand, builtin editors should not create new invalid structure.
Therefore, if the editing host cannot have the paragraphs, inserting paragraph
should cause inserting <br> or \n.

Depends on D188908

Attachment #9348434 - Attachment description: Bug 1840856: Fixed linefeed/linebreak issues for contenteditable. r=masayuki!,#dom-core → WIP: Bug 1840856: Fixed linefeed/linebreak issues for contenteditable. r=masayuki!,#dom-core
Attachment #9348434 - Attachment is obsolete: true

This patch is related to Bug 1840822, which fixes some issues
regarding additional invisible linebreaks needed at the end of
contenteditables.
This patch in particular fixes the case where the user
presses enter at the end of a pre-formatted
contenteditable, e.g.:

<span contenteditable style="display:block;white-space:pre-line">[]</span>

Prior to this patch, only one <br> was added,
the invisible padding linebreak was missing.
With this patch applied, the behaviour should be as expected:

<span contenteditable style="display:block;white-space:pre-line">\n<br></span>

Depends on D188937

Pushed by jjaschke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c4a3975cb52a Add some WPTs for inserting paragraph in elements which cannot contain `<div>` nor `<p>` element r=jjaschke https://hg.mozilla.org/integration/autoland/rev/cbb65dd60bf7 Fixed linefeed/linebreak issues for contenteditable. r=masayuki,dom-core
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/42447 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: