Page MenuHomePhabricator

VisualEditor: templates with custom TemplateData formats beginning with "\n" insert a "<br/>" tag when placed below precisely one new line
Open, MediumPublic

Assigned To
None
Authored By
SUM1
Mar 18 2020, 1:42 AM
Referenced Files
F31688375: image.png
Mar 18 2020, 2:28 AM
F31688373: image.png
Mar 18 2020, 2:28 AM
F31688274: image.png
Mar 18 2020, 1:42 AM
F31688239: image.png
Mar 18 2020, 1:42 AM
F31688277: image.png
Mar 18 2020, 1:42 AM
F31688270: image.png
Mar 18 2020, 1:42 AM
F31688256: image.png
Mar 18 2020, 1:42 AM

Description

I don't know whether this is expected behaviour or not, but it's troublesome.
It occurs on the language Wikipedias, but it doesn't occur on Wikimedia Commons or Wiktionary, which seem to handle new lines differently.

Steps to reproduce:

  1. Have a template with TemplateData with a custom format that begins with "\n". I used a few sandbox templates with sandbox TemplateData in their /doc pages.
    • Example:
    • image.png (86×259 px, 2 KB)
    • (the last "\n" doesn't cause this bug)
  1. Edit a page in VisualEditor on any of the language wikis (English and French tested) but not Wikimedia Commons or Wiktionary (no bug here).
  1. Find a paragraph of text, and add new lines to make space to add a template – but, make sure there is precisely 1 new line between the cursor and the next content above.
    • Example:
    • image.png (123×193 px, 4 KB)
  1. Insert the template.
  1. Switch to source mode, and locate where you inserted the template.

Actual result:

A "<br/>" tag is inserted on the line above the template.

image.png (109×491 px, 7 KB)

Expected result:

No "<br/>" tag is inserted.

Notes:

It does not occur in TemplateWizard or the 2017 wikitext editor.

It also does not occur with 2 or more lines above (most of the time) or 0 lines above.

  • Examples:
  • image.png (181×184 px, 4 KB)

There were a few times it did occur with more than 2 lines above, but only when there were 0 lines below. This did not always happen when there were 0 lines below. I couldn't establish the rule.

  • Example:
  • image.png (446×281 px, 18 KB)
  • (It created these new lines below. They were not there when inserting.)

It does not occur on Wiktionary or Wikimedia Commons, where you cannot insert templates with no blank wikitext lines between each other in VisualEditor. However, even when there is only 1 blank line above the template, the bug does not occur.

  • Example:
    • VisualEditor:
      image.png (286×488 px, 16 KB)
    • Wikitext:
      image.png (266×349 px, 7 KB)