Page MenuHomePhabricator

Line breaks in list items lost on save
Closed, DuplicatePublic

Description

  1. Create or edit a list with one or more items.
  2. Press shift-enter within the list item's text and then enter some more text.
  3. Observe that within the surface, the list item now has text over multiple lines. (correct, as expected)
  4. Save, Or review wikitext diff.

Actual result:

Line break was stripped away and is no longer text. Text unexpectedly now renders next to each other.

Screenshots:

Text enteredLine break added
Screen Shot 2018-03-22 at 15.59.49.png (436×2 px, 166 KB)
Screen Shot 2018-03-22 at 15.59.54.png (478×1 px, 136 KB)
Visual diffWikitext diff
Screen Shot 2018-03-22 at 16.00.00.png (596×1 px, 148 KB)
Screen Shot 2018-03-22 at 16.00.04.png (242×1 px, 59 KB)
Here the problem is visible.

Other information:

While merely an internal detail, I notice that when pressing shift-enter, VisualEditor actually split the list item into two paragraphs - instead of like it did before, which was to internally use a <br> element.

This is significant because when serialising the visual page to Wikitext, we default to the double-linebreak syntax for paragraphs, which is not allowed in list items in Wikitext (because it would end the * bullet list).

On the other hand, serialising <br> is perfectly valid in wikitext.

The following related scenario does work:

  1. Edit a page with a wikitext editor.
  2. Create a regular paragraph and insert <br> in-between two pieces of text.
  3. Create a list with <br> in-between two pieces of text in the lit item.
  4. Save
  5. Edit with VisualEditor.
  6. Observe the line break is rendered just fine. Both in paragraphs and in the list. VisualEditor can render it, edit it, and save/roundtrip.

I also observe that in regular paragraphs, VisualEditor also uses P instead of BR on shift-enter. I do not know if that was changed intentionally. I suppose the difference is small enough that it may be an intentional style decision. However, for list items that is a problem.

I propose three possible ideas as solution:

  1. Make shift-enter insert BR always like before. Enter is not a problem in list items because that adds a new list item, not a paragraph.
  2. Make shift-enter insert BR for list items and P elsewhere.
  3. Make Parsoid serialise paragraphs in list items correctly (e.g. using ugly <p> syntax).

It seems that 1 or 2 would be preferred because a paragraph creates more spacing in a list item than intended. The use of shift-enter is commonly used in different software for the insertion of line breaks (as opposed to new items/paragraphs).

Regression

I don't recall when this last worked, but this definitely worked at some point (it inserted BR for shift-enter). Could be a couple weeks, or maybe even a month or two.