Page MenuHomePhabricator

jquery.makeCollapsible should avoid page scroll when collapsing elements
Closed, ResolvedPublic

Description

(In reply to Bug 27488 comment #28)

Following a link to a section in long discussion page:

  • Click the link.
  • Wait for the page to appear (takes a while since the pages are not cached for

users who are logged in)

  • Notice that you have been sent to a different location. No section header

anywhere near.

  • Try to locate the right position anyway.
  • If you can't find it, click the url bar and press Enter. (Maybe the Reload

button also does it in some browsers.)

Maybe the script resources/jquery/jquery.makeCollapsible.js (the function toggleLinkPremade?) could memorize the current scroll position and restore it right after collapsing an element in the page (I think LQT does something like that). This could help if the element is one of those which are above the current section (currently you may end up a few sections below the one you wanted)


Version: unspecified
Severity: normal

Details

Reference
bz40792

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:02 AM
bzimport added a project: MediaWiki-JavaScript.
bzimport set Reference to bz40792.
bzimport added a subscriber: Unknown Object (MLST).
He7d3r created this task.Oct 5 2012, 11:56 AM

That would be one way to work around it pushing down the page, however this will be fixed in the refactor of jquery.makeCollapsible which will do the initial collapse with CSS instead of JavaScript (so by the time the browser even considers jumping to a position, the collapsing has been long taken care of).

This works because CSS applies retroactively and live. So when the html comes into the parser and is rendered by the browser, the state of expansion or collapse is already applied from the start, no transition.

(this does use javascript, but not inside jquery.makeCollapsible, it will use .client-js .mw-collapsed)

I think that CSS solution would not work for the case where someone is adding the class="mw-collapsible mw-collapsed" from a user script and calling
$(...).makeCollapsible()

(In reply to comment #2)

I think that CSS solution would not work for the case where someone is adding
the class="mw-collapsible mw-collapsed" from a user script and calling
$(...).makeCollapsible()

In that case the element would collapse as soon as the class is added. Calling makeCollapsible will then add the relevant event handlers so that the user can change the state.

Note that if javascript is disabled it will always be shown even if CSS hides it with mw-collapsed because the selector would be prefixed with .client-js (which the mw.page module adds to the document).

Samat added a subscriber: Samat.Mar 21 2016, 3:20 PM
He7d3r removed a subscriber: He7d3r.
He7d3r added a subscriber: He7d3r.

Change 424165 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/core@master] mw-collapsible no longer causes page jump

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

Change 425211 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/core@master] Only load mediawiki.jquery.styles if page HTML suggests needed

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

Change 425211 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/core@master] Skins: getDefaultModules can now define render blocking CSS

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

Change 425211 merged by jenkins-bot:
[mediawiki/core@master] Skins: getDefaultStyles can now define render blocking CSS

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

Change 424165 merged by jenkins-bot:
[mediawiki/core@master] sortable tables/mw-collapsible no longer causes page jump

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

This should be fixed on the beta cluster now. The change was a tricky one and we have almost a week until next train so if anyone reading can spare some time to test this change out on the beta cluster it would be most appreciated :)

Comfr added a subscriber: Comfr.May 4 2018, 7:49 PM

This should be fixed on the beta cluster now. The change was a tricky one and we have almost a week until next train so if anyone reading can spare some time to test this change out on the beta cluster it would be most appreciated :)

I enabled beta in Wikipedia, which gave me MediaWiki version 1.32.0-wmf.2 (bbd5b51). The problem still exists. How should I test the fix?

Jdlrobson raised the priority of this task from Low to Normal.May 7 2018, 6:05 PM
matmarex closed this task as Resolved.May 8 2018, 2:19 PM