I visited Special:Homepage on mobile beta labs and got a popup encouraging me to enable advanced mode. When I agreed, it reloaded the page in advanced mode, but it sent me to my user page instead of Special:Homepage. (Perhaps this is because we set the relevantTitle of Special:Homepage to the user page?)
Steps to reproduce
- Open a new incognito window,
- Login to https://en.m.wikipedia.beta.wmflabs.org/wiki/Special:Homepage as a user with AMC disabled
- When the outreach drawer appears, click the "Enable advanced mode" button
- Notice that you are redirected to the user page instead of back to Special:Homepage
Expected results
- User is redirected back to the page they enabled AMC from (in this case Special:Homepage)
Actual results
- User is redirected to user page
Dev notes
The amc outreach form uses currentPage.js to determine an appropriate redirection. currentPage.js [[ https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/b16895f9483c5949cd18d8b3f8400245f9b1952b/src/mobile.startup/currentPage.js#L25 | uses wgRelevantPageName ]] to determine the current page's title:
mw.Title.newFromText( mw.config.get( 'wgRelevantPageName' ) );
Pages like Special:Homepage and Special:WhatLinksHere can set [[ https://www.mediawiki.org/wiki/Manual:Interface/JavaScript | wgRelevantPageName ]] to something other than the current page's title, however which is why this bug is occurring.
Possible solutions
- Use [[ https://www.mediawiki.org/wiki/Manual:Interface/JavaScript | wgPageName ]] instead of wgRelevantPageName to determine the page to redirect back to. This is what https://gerrit.wikimedia.org/r/531743 attempts to do. This might be simplest solution, however if the user lands on a page with other query params (besides title), these would get dropped upon redirection. We could add another query param returntoquery to prevent this from happening which is what the login link does, but this will probably require some messy/unfun finagling of query params.
- Use the entire relative path to determine what page to redirect to. This is what https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/MobileFrontend/+/531588/ attempts to do, but it seems that using returnto/returntoquery is the popular way to handle this within the mediawiki ecosystem
- Use an ajax request to perform the POST and then refresh the page once successful. However, we would probably have to show a spinner while the request is performed and may have to handle any error messages from the backend. I also think a spinner followed by a full page refresh can be a little jarring to the user.
QA Results
AC | Status | Details |
---|---|---|
1 | ✅ | T230927#5468134 |