From b8f032d26653cd8fb849bfe188d5add83e909fcc Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 8 Nov 2024 14:05:09 +0000 Subject: [PATCH] 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 --- .../ve.init.mw.DesktopArticleTarget.js | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js index 7fc7f31652..3228048749 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js @@ -889,26 +889,23 @@ 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 ); - // Title::getNamespaceKey() - let namespaceKey = namespaceName.toLowerCase() || 'main'; - if ( namespaceKey === 'file' ) { - namespaceKey = 'image'; - } - let namespaceTabId; - // SkinTemplate::buildContentNavigationUrls() - if ( isTalkNamespace ) { - namespaceTabId = 'ca-talk'; - } 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 ) ); + const namespaceNumber = mw.config.get( 'wgNamespaceNumber' ); + const namespaceName = mw.config.get( 'wgCanonicalNamespace' ); + const isTalkNamespace = mw.Title.isTalkNamespace( namespaceNumber ); + // Title::getNamespaceKey() + let namespaceKey = namespaceName.toLowerCase() || 'main'; + if ( namespaceKey === 'file' ) { + namespaceKey = 'image'; } + let namespaceTabId; + // SkinTemplate::buildContentNavigationUrls() + if ( isTalkNamespace ) { + namespaceTabId = 'ca-talk'; + } else { + namespaceTabId = 'ca-nstab-' + namespaceKey; + } + $( '#ca-view' ).add( '#' + namespaceTabId ).find( 'a' ) + .on( 'click.ve-target', this.onViewTabClick.bind( this ) ); // Used by Extension:GuidedTour mw.hook( 've.skinTabSetupComplete' ).fire();