Page MenuHomePhabricator

After switching to visual the template has been expanded to include editable text
Closed, ResolvedPublic

Description

This task is about resolving an issue where templates can become expanded when someone switches from the Reply tool's source mode to its visual mode.

Behavior

  1. Visit: https://en.wikipedia.org/wiki/User_talk:PPelberg_(WMF)/sandbox?dtenable=1
  2. Click any "Reply" link
  3. Type the following in the tool's source mode:
Hello
{{quote|world}}
  1. Switch the tool's visual mode
  2. Switch back to the tool's source mode

Actual

  1. ❗️Notice the source mode contains the following: Hello {{quote|world}}<blockquote class="templatequote">world</blockquote>

Expected

  1. ✅Notice the source mode contains the following:
Hello
{{quote|world}}

Event Timeline

The issue here is with the list-unwrapping we do after switching. The quote template has template styles so in HTML it is:

<dd><style typeof="mw:Translcusion" about="mwt1">...</style><blockquote about="mwt1">rendering</blockquote></dd>

When we go to unwrap this, the <style> tag is considered inline so it get's <p>-wrapped, but the blockquote doesn't. As the blockquote is now no-longer a sibling of <style> it is no longer part of the transclusion.

In general any template which consists of mixed inline and block tags will break like this. We have logic in VE to handle this, but the unwrapping happens before we convert to a VE doc.

I don't think there is a clean solution to this, so I would prefer we went with T256150 and just prevent switching when templates are used.

I don't think there is a clean solution to this, so I would prefer we went with T256150 and just prevent switching when templates are used.

Today, we decided on moving forward with T256150 for reasons explained in T256150#6265908.

As such, I am moving this ticket to the backlog.

We have since prevented users switching to visual mode when templates are being used, so this isn't an issue any more. If we do add support templates in the future, it would be by encapsulating the whole comment and it is unlikely this bug would come back.

image.png (189×543 px, 33 KB)

Esanders claimed this task.
Esanders attached a referenced file: F35513669: image.png. (Show Details)