From ae554cdd6682e5697a7b333a542dbfd7d3692ecf Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Tue, 22 Feb 2022 15:18:14 +0000 Subject: [PATCH] Fix legacy hint URI on mobile Bug: T302307 Change-Id: I7ce370bb011f0b30505c1b195bf6c96317b159e7 --- modules/NewTopicController.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/NewTopicController.js b/modules/NewTopicController.js index 7cc0e8764..e98406a66 100644 --- a/modules/NewTopicController.js +++ b/modules/NewTopicController.js @@ -148,13 +148,22 @@ NewTopicController.prototype.setupTopicHint = function () { // T106244: URL encoded values using fallback 8-bit encoding (invalid UTF-8) cause mediawiki.Uri to crash return; } - legacyURI.query.action = 'edit'; - legacyURI.query.section = 'new'; + var fragment = ''; + if ( OO.ui.isMobile() ) { + // mw.Uri encodes link fragments, converting to '/' to '%2F', which breaks the router + fragment = '#/talk/new'; + delete legacyURI.query.action; + delete legacyURI.query.section; + } else { + legacyURI.query.action = 'edit'; + legacyURI.query.section = 'new'; + } legacyURI.query.dtenable = '0'; // This is not a real valid value for 'editintro', but we look for it elsewhere to generate our own edit notice legacyURI.query.editintro = 'mw-dt-topic-hint'; + this.topicHint = new OO.ui.MessageWidget( { - label: mw.message( 'discussiontools-newtopic-legacy-hint', legacyURI.toString() ).parseDom(), + label: mw.message( 'discussiontools-newtopic-legacy-hint', legacyURI.toString() + fragment ).parseDom(), icon: 'article' } ); this.topicHint.$element.addClass( 'ext-discussiontools-ui-newTopic-hint' );