New issue
Advanced search Search tips

Issue 714555 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Feature



Sign in to add a comment

contenteditable: chrome inserts divs in p for line breaks

Reported by robin.fo...@artlogic.net, Apr 24 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

Steps to reproduce the problem:
1. <p contenteditable="true">hello</p>
2. focus on the ocntenteditable element and hit enter to add line breaks

What is the expected behavior?
add line breaks but don't add div elements inside a p element

What went wrong?
chrome inserts div elements inside the p element which is not valid html. the problem isn't immediately apparent but if you were to save the html and re-render it the markup would be altered by the browser

Did this work before? Yes not sure

Does this work in other browsers? N/A

Chrome version: 57.0.2987.133  Channel: stable
OS Version: OS X 10.12.2
Flash Version: 

i think this was working at some point but can't say for sure
 
test.html
35 bytes View Download
Components: Blink
Components: -Blink Blink>Editing

Comment 3 by yosin@chromium.org, Apr 28 2017

Components: -Blink>Editing Blink>Editing>Command
Labels: -Pri-2 -Type-Bug-Regression Pri-3 Type-Feature
Status: Available (was: Unconfirmed)
We insert empty DIV for Enter key. We may want to change this behavior.
i would be interested to know why a DIV is used in any case, to me it seems more sensible to use BR as it works in a more consistent way. For example if I wanted to take some text written in a contenteditable block element and put it in an inline element I would have to convert the emptys DIV elements to BR. If the browser just used BR for all cases I wouldn't be faced with this problem.

Comment 5 by dtoybo...@gmail.com, Apr 18 2018

FYI: Firefox inserts <br> when:
* there is no block level ancestor
https://searchfox.org/mozilla-central/rev/f65d7528e34ef1a7665b4a1a7b7cdb1388fcd3aa/editor/libeditor/HTMLEditRules.cpp#1683,1687,1689
* the block level parent is editing host but it cannot contain the default paragraph separator (<p> or <div>)
https://searchfox.org/mozilla-central/rev/f65d7528e34ef1a7665b4a1a7b7cdb1388fcd3aa/editor/libeditor/HTMLEditRules.cpp#1694-1696
* there is no block parent which can contain the default paragraph separator
https://searchfox.org/mozilla-central/rev/f65d7528e34ef1a7665b4a1a7b7cdb1388fcd3aa/editor/libeditor/HTMLEditRules.cpp#1701,1706-1707
 Issue 834217  has been merged into this issue.

Sign in to add a comment