Page MenuHomePhabricator

Special:ExpandTemplates does not load module 'mediawiki.toc'
Closed, DeclinedPublic


Steps to reproduce:

Current result: The TOC does not have a button to hide the TOC.
Expected result: The TOC should have a button to hide the TOC. This is occurs when the module mediawiki.toc is loaded.

The module mediawiki.toc is a less important module. But there may be more important module which should be loaded also an ExpandTemplate preview.

Event Timeline

The module '' gets loaded on expand template preview when including with {{:Help:Images}} but not the module mediawiki.toc.

Before c7e00974c7eb1cd33783f4f0354de766e70ce3c1 Special:ExpandTemplates loaded the module mediawiki.toc on preview.

This seems by design. SpecialExpandTemplates calls OutputPage::addParserOutputContent which intentionally does not call addParserOutputMetadata.

This means that the following don't apply on ExpandTemplates:

  • Language links, Indicators. (Sidebar, Header)
  • Talk link / New section link. (Navigation tabs)
  • Parser limit report. (Invisible - HTML comment)

And more things, such as loading of OOUI, and indeed (as of c7e00974c7e) the loading of mediawiki.toc.

I think this is by design given the page is not meant to be an interactive preview for reading, but rather, just showing the plain HTML as it would be after the Parser expands the template.

If this should be more like edit preview, then one would need to call addParserOutput() instead. But that may do unexpected things. Worth a try?

Declining for now. ExpandTemplates has never been an accurate edit preview. Specifically, any visual rendering controlled by the skin is intentionally excluded. This means that the special page will not have categories, language links, "Edit" tab, "New section", "View history" tab etc. It also does not get Skin-controlled modifications, such as customised edit-section links, and (as of last year) interactive table of contents.

I understand that the lack of interactive TOC may seem like a regression, but in this case it is not specific to TOC. The TOC implementation merely moved from one area to another, and the other area was already intentionally disabled.

The output renders without problems though, and there are no broken buttons (e.g. it's not like the TOC shows a "hide" button that doesn't work, it just renders correctly without the interactive part).