Follow-up to T167522. All links are to enwiki.
The mw-collapsible class in MediaWiki core is supposed to replace the old collapsible class and NavFrames, both deprecated gadgets. However, there are two issues which hinder the replacement of NavFrames:
- There is no way to align the new buttons to the left (to the right for RTL wikis), at least without some creative hacks (and even then only in tables and not in divs). (NavFrames also require a hack, but this can be done without any weird visual output most of the time and it works in divs.) Template:Routemap currently uses a hack where a fake empty header cell is placed on the left side of a table, and the JS inserts the button there instead of in the rightmost cell.
- Centred header text in NavFrames doesn't move when the button is clicked. A separate div with a margin to the left and right was required for this in Template:Navbox (it uses a table, but same thing happens in divs; see Template:Hidden/testcases).
One blocker to the replacement of the old collapsible class was that the new button couldn't have its colour changed and didn't display well on coloured backgrounds, but this was solved by @TheDJ using this one weird trick in MediaWiki:Common.js. This is not in standard MediaWiki, but should be relatively easy to implement once TemplateStyles is enabled (some time after June 2018).