Last modified: 2014-10-09 07:29:37 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 T73796, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 71796 - Media Viewer: Scroll position is lost on original page after accessing the original file
Media Viewer: Scroll position is lost on original page after accessing the or...
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
MultimediaViewer (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-08 14:05 UTC by Keegan Peterzell
Modified: 2014-10-09 07:29 UTC (History)
5 users (show)

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


Attachments

Description Keegan Peterzell 2014-10-08 14:05:29 UTC
When a user clicks on an image in a page to open Media Viewer and then proceeds to view the original file, previous page position is lost when navigating back to the host page.

1. Go to any article with images and scroll down a way.
2. Click on any image.
3. In Media Viewer, click the image again to go to the full-size version.
4. Finish looking at the full-size version, so click browser "back" button and then "X" in MV, or click browser "back" button twice.
5. You return to the top of the original page, not where you were scrolled to
Comment 1 Gilles Dubuc 2014-10-08 14:07:18 UTC
This is default browser behavior when reopening a hash link through the history. We can build something specific to act as a workaround, like storing the scroll position for a given hash in local storage, or making the scroll position part of the hash code.
Comment 2 Tisza Gergő 2014-10-08 14:33:20 UTC
This should not be the default behavior for at least some browsers, as they normally cache the page state in memory for history navigation ("bfcache"). We should figure out what in MediaViewer (or MediaWiki) breaks bfcache.

https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching
http://stackoverflow.com/questions/1195440/ajax-back-button-and-dom-updates/1195934#1195934
Comment 3 Gilles Dubuc 2014-10-08 14:35:25 UTC
I think the cache is doing what it's supposed to. If you have media viewer open, the page scroll is 0. So at the time you move to another page, that's what the browser remembers and restores.
Comment 4 Gilles Dubuc 2014-10-08 14:35:59 UTC
I.e. the browser can't be aware that media viewer "isn't really the page".
Comment 5 Tisza Gergő 2014-10-08 14:36:18 UTC
As for storing page location in localStorage, we are building hack upon hack to pretend we have a zoom function. If the current state is not acceptable, instead of further twiddling we should just suck it up and actually build one.
Comment 6 Gilles Dubuc 2014-10-08 14:38:18 UTC
I didn't suggest that we should implement this hack, I'm just listing possibilities for posterity :) I personally think that trying to compensate for the browser's natural behavior isn't the way to go.
Comment 7 Tisza Gergő 2014-10-08 14:40:24 UTC
(In reply to Gilles Dubuc from comment #3)
> I think the cache is doing what it's supposed to. If you have media viewer
> open, the page scroll is 0. So at the time you move to another page, that's
> what the browser remembers and restores.

MediaViewer stores the scroll position in a JS variable. If bfcache worked properly, upon backnavigation the browser would reload the page with MediaViewer open and the scroll position variable set, and MediaViewer uses that to restore the scroll position on close.

What actually happens is that the page is restored in its initial position, with MediaViewer closed; and the scroll position is reset due to the hash, so by the time MV opens and stores the scroll position it's zeroed out.
Comment 8 Gilles Dubuc 2014-10-08 14:41:17 UTC
On the topic of relying on the browser, I guess then the solution is to close Media Viewer's UI like ninjas onbeforeunload, but without clearing the hash. This way when navigating back, the browser scroll cache kicks in, and the hash makes media viewer open.

Still an ugly hack... albeit a much faster one to implement.
Comment 9 Tisza Gergő 2014-10-09 07:29:37 UTC
Opened bug 71868 about the bfcache issue.

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


Navigation
Links