Move mmv-close event trigger higher up in lightboxinterface/unattach

This avoids a bug with Firefox's automatic scroll restoration logic,
which seems to always jump to the top of the page upon closing MMV.

Bug: T229484
Change-Id: Ia4261ce268df4d8fb07b4813a6ae72ad88728e91
This commit is contained in:
Matthias Mullie 2020-01-07 09:55:09 +01:00 committed by Krinkle
parent 6bdae911b8
commit ca1364928c

View file

@ -253,6 +253,14 @@
LIP.unattach = function () { LIP.unattach = function () {
mw.mmv.actionLogger.log( 'close' ); mw.mmv.actionLogger.log( 'close' );
// We trigger this event on the document because unattach() can run
// when the interface is unattached
// We're calling this before cleaning up (below) the DOM, as that
// appears to have an impact on automatic scroll restoration (which
// might happen as a result of this being closed) in FF
$( document ).trigger( $.Event( 'mmv-close' ) )
.off( 'jq-fullscreen-change.lip' );
// Has to happen first so that the scroller can freeze with visible elements // Has to happen first so that the scroller can freeze with visible elements
this.panel.unattach(); this.panel.unattach();
@ -284,11 +292,6 @@
prev: [ 'emit', 'prev' ] prev: [ 'emit', 'prev' ]
} ); } );
// We trigger this event on the document because unattach() can run
// when the interface is unattached
$( document ).trigger( $.Event( 'mmv-close' ) )
.off( 'jq-fullscreen-change.lip' );
this.attached = false; this.attached = false;
}; };