Page MenuHomePhabricator

Cloned collapsible contents are no longer collapsible
Closed, ResolvedPublic

Description

To reproduce go to any page with collapsible content, e.g. https://en.wikipedia.org/wiki/Help:Table#Using_class_mw-collapsible
Execute in the console:

$clone = $('#bodyContent').clone();
mw.hook('wikipage.content').fire($clone);
$('#bodyContent').replaceWith($clone);

The collapsible content is now no longer collapsible (but at least sortable tables are still sortable). Note that it doesn't work with the following code, either (and this breaks sortable tables, too: bug 38704):

$clone = $('#bodyContent').clone(true);
$('#bodyContent').replaceWith($clone);

What I'm currently doing (in a script that shows footnotes in a popup and should be able to show collapsible and sortable tables as such) is an additional $clone.find('.mw-collapsible-toggle').remove(); between the first and second line, but this is more a hack than a solution:

$clone = $('#bodyContent').clone();
$clone.find('.mw-collapsible-toggle').remove();
mw.hook('wikipage.content').fire($clone);
$('#bodyContent').replaceWith($clone);

This is probably easily fixable: The cloned handles are recognized as such, but when the user clicks on them the content isn't collapsed/expanded, because they are links. If the pass-through behavior wasn't applied to links with href="#", the cloned contents will probably be collapsible without hacks.


Version: 1.24rc
Severity: normal

Details

Reference
bz69288

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 3:30 AM
bzimport added a project: MediaWiki-JavaScript.
bzimport set Reference to bz69288.
bzimport added a subscriber: Unknown Object (MLST).
Schnark created this task.Aug 8 2014, 9:26 AM

Hmm, yeah. The proposed fix looks reasonable to me. This would be a slightly hacky workaround, but it shouldn't cause any problems. Perhaps a better long-term solution would be to make the toggles actual buttons, but we can think about that some other time.

(Nitpick correction: the collapsibility still works, but you need to click on one of the brackets '[]', and not on the link itself.)

Change 224758 had a related patch set uploaded (by Gerrit Patch Uploader):
jquery.makeCollapsible: Make it possible to clone a collapsible

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

matmarex closed this task as Resolved.Jul 20 2015, 12:03 PM
matmarex assigned this task to Schnark.
matmarex removed a project: Patch-For-Review.
matmarex set Security to None.
matmarex removed a subscriber: wikibugs-l-list.

Change 224758 merged by jenkins-bot:
jquery.makeCollapsible: Make it possible to clone a collapsible

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