Last modified: 2012-12-31 14:22:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T42792, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 40792 - jquery.makeCollapsible should avoid page scroll when collapsing elements
jquery.makeCollapsible should avoid page scroll when collapsing elements
Status: NEW
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
unspecified
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on: 40812
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-05 11:56 UTC by Helder
Modified: 2012-12-31 14:22 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Helder 2012-10-05 11:56:20 UTC
(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)
Comment 1 Krinkle 2012-10-05 21:03:36 UTC
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)
Comment 2 Helder 2012-10-05 23:37:17 UTC
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()
Comment 3 Krinkle 2012-10-06 07:25:02 UTC
(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).

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links