Page MenuHomePhabricator

VE displays multiple placeholders when editor only contains a single template
Closed, ResolvedPublic1 Estimated Story Points

Description

Found when verifying T94569 (the template example is from the ticket).

  1. The following template is displayed on multiple lines

{{User:ET1|title=Barack Obama|project1=WikiProject United States}}

  1. Insert that template in topic summary and Save.
  1. Then click 'Edit the topic summary'. Switch to VE. The multiple 'Describe briefly the outcome of this discussion' are displayed.

Screen Shot 2015-09-01 at 1.33.27 PM.png (361×774 px, 87 KB)

Note:

  • does not happen with the same template when it's inserted in a post
  • other templates (e.g. {{CURRENTTIMESTAMP}}) -inserted into Topic summary do not produce multiple lines of 'Describe briefly...'

Event Timeline

Etonkovidova raised the priority of this task from to Needs Triage.
Etonkovidova updated the task description. (Show Details)
Etonkovidova subscribed.

When adding this template in wikitext and then looking at it in VE, the placeholder transforms into this:

<div class="ve-ui-surface ve-ui-surface-dir-"><div class="ve-ui-surface-placeholder"><p about="#mwt1" typeof="mw:Transclusion" id="mwAQ" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;User:ET1&quot;,&quot;href&quot;:&quot;./User:ET1&quot;},&quot;params&quot;:{&quot;title&quot;:{&quot;wt&quot;:&quot;Barack Obama&quot;},&quot;project1&quot;:{&quot;wt&quot;:&quot;WikiProject United States&quot;}},&quot;i&quot;:0}}]}" class="ve-ce-mwTransclusionNode ve-ce-focusableNode" contenteditable="false">Describe briefly the outcome of this discussion</p><span about="#mwt1" class="ve-ce-mwTransclusionNode ve-ce-focusableNode" contenteditable="false">Describe briefly the outcome of this discussion</span><p about="#mwt1" class="ve-ce-mwTransclusionNode ve-ce-focusableNode" contenteditable="false">Describe briefly the outcome of this discussion</p></div><div class="ve-ce-surface notranslate"><div class="ve-ce-branchNode ve-ce-documentNode mw-content-ltr noime" contenteditable="true" spellcheck="true" lang="en" dir="ltr"><div class="ve-ce-branchNode-slug ve-ce-branchNode-blockSlug"><div class="oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-iconElement oo-ui-labelElement oo-ui-buttonWidget" aria-disabled="false"><a class="oo-ui-buttonElement-button" role="button" tabindex="0" aria-disabled="false" rel="nofollow"><span class="oo-ui-iconElement-icon oo-ui-icon-add"></span><span class="oo-ui-labelElement-label">Insert paragraph</span><span class="oo-ui-indicatorElement-indicator"></span></a></div></div><p about="#mwt1" typeof="mw:Transclusion" id="mwAQ" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;User:ET1&quot;,&quot;href&quot;:&quot;./User:ET1&quot;},&quot;params&quot;:{&quot;title&quot;:{&quot;wt&quot;:&quot;Barack Obama&quot;},&quot;project1&quot;:{&quot;wt&quot;:&quot;WikiProject United States&quot;}},&quot;i&quot;:0}}]}" class="ve-ce-mwTransclusionNode ve-ce-focusableNode ve-ce-leafNode" contenteditable="false">Article title: <b><a rel="mw:WikiLink" href="http://en.wikipedia.beta.wmflabs.org/wiki/Barack_Obama" title="Barack Obama">Barack Obama</a></b></p><span about="#mwt1" class="ve-ce-mwTransclusionNode ve-ce-focusableNode ve-ce-leafNode" contenteditable="false">

</span><p about="#mwt1" class="ve-ce-mwTransclusionNode ve-ce-focusableNode ve-ce-leafNode" contenteditable="false">Status: <b><span typeof="mw:Nowiki">{{</span>#ifexist:Barack Obama|<span typeof="mw:Image"><span><img alt="" resource="./File:Pictogram_voting_keep-light-green.svg" src="http://upload.beta.wmflabs.org/wikipedia/en/thumb/d/d2/Pictogram_voting_keep-light-green.svg/20px-Pictogram_voting_keep-light-green.svg.png" data-file-width="250" data-file-height="250" data-file-type="drawing" height="20" width="20"></span></span> Page is live! 
</b></p><div class="ve-ce-branchNode-slug ve-ce-branchNode-blockSlug ve-ce-branchNode-blockSlug-focused"><div class="oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-iconElement oo-ui-labelElement oo-ui-buttonWidget" aria-disabled="false"><a class="oo-ui-buttonElement-button" role="button" aria-disabled="false" rel="nofollow"><span class="oo-ui-iconElement-icon oo-ui-icon-add"></span><span class="oo-ui-labelElement-label">Insert paragraph</span><span class="oo-ui-indicatorElement-indicator"></span></a></div></div></div><div class="ve-ce-surface-paste noime" tabindex="-1" contenteditable="true">Article title: Barack Obama

Status: {{#ifexist:Barack Obama| Page is live!</div></div><div class="ve-ui-overlay-local ve-ui-overlay"><div><div class="ve-ce-surface-deactivatedSelection"></div></div><div><div class="ve-ce-surface-highlights"><div class="ve-ce-surface-highlights-focused"></div><div class="ve-ce-surface-highlights-blurred"></div><div class="ve-ce-surface-dropMarker oo-ui-element-hidden"></div></div></div><div></div><div><div class="ve-ui-context ve-ui-desktopContext oo-ui-element-hidden" style="left: -17.2188px; top: -318.906px;"><div class="oo-ui-widget oo-ui-widget-enabled oo-ui-popupWidget-anchored oo-ui-popupWidget oo-ui-element-hidden" aria-disabled="false"><div class="oo-ui-popupWidget-popup" style="width: 400px; height: 76px; margin-left: -22px;"><div class="oo-ui-popupWidget-head oo-ui-element-hidden"><span class="oo-ui-labelElement-label"></span><div class="oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-iconElement oo-ui-buttonWidget" aria-disabled="false"><a class="oo-ui-buttonElement-button" role="button" tabindex="0" aria-disabled="false" rel="nofollow"><span class="oo-ui-iconElement-icon oo-ui-icon-close"></span><span class="oo-ui-labelElement-label"></span><span class="oo-ui-indicatorElement-indicator"></span></a></div></div><div class="oo-ui-clippableElement-clippable oo-ui-popupWidget-body"><div class="ve-ui-context-menu ve-ui-desktopContext-menu"></div><div class="oo-ui-windowManager ve-ui-dir-block-ltr"></div></div><div class="oo-ui-popupWidget-footer oo-ui-element-hidden"></div></div><div class="oo-ui-popupWidget-anchor"></div></div></div></div></div></div>

The placeholder has transclusion in it... (!!)

It looks like a VE bug to me.

There are two bugs here:

First, there's the fact that a placeholder appears at all. There's a template in the editor, so the editor isn't empty and the placeholder shouldn't appear. This happens because ve.dm.ElementLinearData#hasContent considers any document with two (or fewer) non-internal elements to be empty. The justification for this is that <p></p> should be considered empty, but in our case the document is <mwTransclusionBlock></mwTransclusionBlock> and that IMO should not be considered empty. Perhaps this could be modified to only return true if the element in question is a ContentBranchNode.

Second, there's the fact that the placeholder appears three times. This happens because ve.ui.Surface#updatePlaceholder does something like firstNode.$element.clone().text( this.placeholder ) to generate the placeholder. This is a nice touch to ensure visual consistency between the placeholder and the node you're about to type into, but in our case firstNode.$element is a collection of multiple elements (due to about grouping), and .text() happily overwrites the contents of each element in the collection individually. The HTML of the placeholder ends up being something like:

<p about="#mwt1" typeof="mw:Transclusion" id="mwAQ" data-mw="..." class="ve-ce-mwTransclusionNode ve-ce-focusableNode" contenteditable="false">Placeholder text</p>
<span about="#mwt1" class="ve-ce-mwTransclusionNode ve-ce-focusableNode" contenteditable="false">Placeholder text</span>
<p about="#mwt1" class="ve-ce-mwTransclusionNode ve-ce-focusableNode" contenteditable="false">Placeholder text</p>
Catrope renamed this task from Topic summary edited in VE: Template displays multiple 'Describe briefly the outcome of this discussion' to VE displays multiple placeholders when editor only contains a single template.Sep 7 2015, 6:53 PM
Catrope set Security to None.

Change 236791 had a related patch set uploaded (by Esanders):
ElementLinearData: Add extra check to hasContent

https://gerrit.wikimedia.org/r/236791

I think fixing the first issue makes the assumption which caused the second issue valid again.

Change 236791 merged by jenkins-bot:
ElementLinearData: Add extra check to hasContent

https://gerrit.wikimedia.org/r/236791

Jdforrester-WMF assigned this task to Esanders.
Jdforrester-WMF edited a custom field.