mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 17:14:42 +00:00
Support '&editintro=…' etc. on subsequent loads via page tabs
Before this change DesktopArticleTarget's history management was not working correctly because .currentUrl was not being updated on every activation, and we worked around this problem by activating it in a different way on subsequent loads in DesktopArticleTarget.init. Fix the first bug by updating .currentUrl whenever we activate it, and remove the guards around the normal way of activating it, which fixes the parsing of 'editintro' parameter. Bug: T56029 Change-Id: Ifd6af60cdf1d2c87536017b316ab8da1f5133400
This commit is contained in:
parent
bcabb774ab
commit
eedafae69e
|
@ -1094,8 +1094,8 @@ ve.init.mw.DesktopArticleTarget.prototype.updateHistoryState = function () {
|
|||
var veaction = this.getDefaultMode() === 'visual' ? 'edit' : 'editsource',
|
||||
section = this.section;
|
||||
|
||||
// Push veaction=edit(source) url in history (if not already. If we got here by a veaction=edit(source)
|
||||
// permalink then it will be there already and the constructor called #activate)
|
||||
// Push veaction=edit(source) url in history (if not already present).
|
||||
// If we got here from DesktopArticleTarget.init, then it will be already present.
|
||||
if (
|
||||
!this.actFromPopState &&
|
||||
(
|
||||
|
|
|
@ -600,6 +600,7 @@
|
|||
|
||||
var deactivating = target.deactivatingDeferred || $.Deferred().resolve();
|
||||
return deactivating.then( function () {
|
||||
target.currentUrl = new URL( location.href );
|
||||
var activatePromise = target.activate( dataPromise );
|
||||
|
||||
// toolbarSetupDeferred resolves slightly before activatePromise, use done
|
||||
|
@ -638,17 +639,15 @@
|
|||
trackActivateStart( { type: 'page', mechanism: mw.config.get( 'wgArticleId' ) ? 'click' : 'new', mode: mode }, linkUrl );
|
||||
|
||||
if ( !active ) {
|
||||
if ( url.searchParams.get( 'action' ) !== 'edit' && !( url.searchParams.get( 'veaction' ) in veactionToMode ) ) {
|
||||
// Replace the current state with one that is tagged as ours, to prevent the
|
||||
// back button from breaking when used to exit VE. FIXME: there should be a better
|
||||
// way to do this. See also similar code in the DesktopArticleTarget constructor.
|
||||
history.replaceState( { tag: 'visualeditor' }, '', url );
|
||||
// Set action=edit or veaction=edit/editsource
|
||||
// Use linkUrl to preserve parameters like 'editintro' (T56029)
|
||||
history.pushState( { tag: 'visualeditor' }, '', linkUrl || ( mode === 'source' ? veEditSourceUrl : veEditUrl ) );
|
||||
// Update URL instance
|
||||
url = linkUrl || veEditUrl;
|
||||
}
|
||||
// Replace the current state with one that is tagged as ours, to prevent the
|
||||
// back button from breaking when used to exit VE. FIXME: there should be a better
|
||||
// way to do this. See also similar code in the DesktopArticleTarget constructor.
|
||||
history.replaceState( { tag: 'visualeditor' }, '', url );
|
||||
// Set action=edit or veaction=edit/editsource
|
||||
// Use linkUrl to preserve parameters like 'editintro' (T56029)
|
||||
history.pushState( { tag: 'visualeditor' }, '', linkUrl || ( mode === 'source' ? veEditSourceUrl : veEditUrl ) );
|
||||
// Update URL instance
|
||||
url = linkUrl || veEditUrl;
|
||||
|
||||
activateTarget( mode, section, undefined, modified );
|
||||
}
|
||||
|
@ -1262,14 +1261,12 @@
|
|||
trackActivateStart( { type: 'section', mechanism: section === 'new' ? 'new' : 'click', mode: mode }, linkUrl );
|
||||
|
||||
if ( !active ) {
|
||||
if ( url.searchParams.get( 'action' ) !== 'edit' && !( url.searchParams.get( 'veaction' ) in veactionToMode ) ) {
|
||||
// Replace the current state with one that is tagged as ours, to prevent the
|
||||
// back button from breaking when used to exit VE. FIXME: there should be a better
|
||||
// way to do this. See also similar code in the DesktopArticleTarget constructor.
|
||||
history.replaceState( { tag: 'visualeditor' }, '', url );
|
||||
// Use linkUrl to preserve the 'section' parameter and others like 'editintro' (T56029)
|
||||
history.pushState( { tag: 'visualeditor' }, '', linkUrl );
|
||||
}
|
||||
// Replace the current state with one that is tagged as ours, to prevent the
|
||||
// back button from breaking when used to exit VE. FIXME: there should be a better
|
||||
// way to do this. See also similar code in the DesktopArticleTarget constructor.
|
||||
history.replaceState( { tag: 'visualeditor' }, '', url );
|
||||
// Use linkUrl to preserve the 'section' parameter and others like 'editintro' (T56029)
|
||||
history.pushState( { tag: 'visualeditor' }, '', linkUrl );
|
||||
// Update URL instance
|
||||
url = linkUrl;
|
||||
|
||||
|
|
Loading…
Reference in a new issue