Handle view tab clicks even on edit pages

This allows the proper "discard changes" dialog to show.
A few more steps of the teardown now happen in the client,
but eventually in DesktopArticleTarget#teardown we check
again if we weren't on a view page and redirect (as this
is what we do after save).

Bug: T379367
Change-Id: I995649f37e5d841b6c1784a74f3bd353adfbe69f
This commit is contained in:
Ed Sanders 2024-11-08 14:05:09 +00:00
parent d414ced79c
commit b8f032d266

View file

@ -889,7 +889,6 @@ ve.init.mw.DesktopArticleTarget.prototype.onToolbarMetaButtonClick = function ()
* 'Edit' and single edit tab are bound in mw.DesktopArticleTarget.init.
*/
ve.init.mw.DesktopArticleTarget.prototype.setupSkinTabs = function () {
if ( this.isViewPage ) {
const namespaceNumber = mw.config.get( 'wgNamespaceNumber' );
const namespaceName = mw.config.get( 'wgCanonicalNamespace' );
const isTalkNamespace = mw.Title.isTalkNamespace( namespaceNumber );
@ -905,10 +904,8 @@ ve.init.mw.DesktopArticleTarget.prototype.setupSkinTabs = function () {
} else {
namespaceTabId = 'ca-nstab-' + namespaceKey;
}
// Allow instant switching back to view mode, without refresh
$( '#ca-view' ).add( '#' + namespaceTabId ).find( 'a' )
.on( 'click.ve-target', this.onViewTabClick.bind( this ) );
}
// Used by Extension:GuidedTour
mw.hook( 've.skinTabSetupComplete' ).fire();