Page MenuHomePhabricator

Router.prototype.navigate only works with hash fragments and doesn't support replace state
Closed, ResolvedPublic5 Story Points

Description

Precursor

  • This task signals a context switch. Before placing in the sprint, consider the implications of other inflight work.

To remove hacks in MobileFrontend/Minerva we need a reliable way to call replaceState to update the URI at any point in time. This will allow us to fix bugs such as T206347

oojs-router is incomplete.

It should also support paths and replacing the current URL
e.g.

router.navigator( 'foo' ); // changes to #foo

router.navigator( { href: '/foo' } ) // changes to /foo

router.navigator( { href: '/foo', search: '#foo' } ) // changes to /foo#foo


router.navigator( { href: '/foo', search: '#foo' }, true ) // changes to /foo#foo using replaceState

Acceptance criteria

  • Since this code is heavily used by the MobileFrontend's overlay system to mitigate risk we advise rather than extending/overloading the navigator function adding a new function e.g. navigatorReplaceState to provide that functionality.
  • All browsers we support make use of history.replaceState https://caniuse.com/#search=history so no fallback in necessary

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 8 2018, 12:07 AM
Jdlrobson renamed this task from Router.prototype.navigate only works with hash fragments to Router.prototype.navigate only works with hash fragments and doesn't support replace state.Mar 21 2018, 9:06 PM
Jdlrobson updated the task description. (Show Details)
ovasileva set the point value for this task to 5.Oct 10 2018, 4:41 PM
Jdlrobson updated the task description. (Show Details)Oct 10 2018, 4:42 PM
Jdlrobson raised the priority of this task from Normal to High.Oct 10 2018, 4:50 PM
Jdlrobson updated the task description. (Show Details)Oct 10 2018, 6:28 PM
Jdlrobson lowered the priority of this task from High to Normal.Nov 15 2018, 7:03 PM

Not currently mapping to any of goals directly.

Change 481955 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[oojs/router@master] OOjs UI Router should support replaceState

https://gerrit.wikimedia.org/r/481955

simon04 added a subscriber: simon04.Jan 3 2019, 1:50 PM

Change 482686 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/core@master] Upgrade router to latest version

https://gerrit.wikimedia.org/r/482686

Change 481955 merged by jenkins-bot:
[oojs/router@master] OOjs Router method to provide access to replaceState

https://gerrit.wikimedia.org/r/481955

Change 482686 abandoned by Jdlrobson:
Upgrade router to latest version

Reason:
Done in https://gerrit.wikimedia.org/r/488558

https://gerrit.wikimedia.org/r/482686

Jdlrobson claimed this task.Feb 8 2019, 7:27 PM

I think this got released in https://gerrit.wikimedia.org/r/488558. Will take a look and sign this off.

Jdlrobson closed this task as Resolved.Feb 12 2019, 12:28 AM

I've validated the behaviour is expected on https://en.m.wikipedia.beta.wmflabs.org/wiki/Main_Page

var router = mw.loader.require('mediawiki.router');
router.navigateTo('Title', { path: '/foo' } );
router.navigateTo('Title', { path: '#bar' } );
router.navigateTo('Title', { path: '#nobar', useReplaceState: true } );

Clicking back:
Expected:
#/foo, initial page (e.g. not possible to get to #bar)

Jdlrobson updated the task description. (Show Details)Feb 12 2019, 12:28 AM