Page MenuHomePhabricator

OOjs Router should support replacing the current entry in the history
Open, Needs TriagePublic

Description

Right now, the Router only has a navigate method that pushes a new entry in the document history.
OOjs Router should support replacing the current entry in the history.

Illustration

History has A.
router.navigate( 'B' );
History has A, B.
router.navigate( 'C' );
History has A, B, C.
window.history.back() goes back to B.
window.history.back() goes back to A.
Goal:
History has A.
router.navigate( 'B' );
History has A, B.
router.navigate( 'C', { replace: true } );
History has A, C.
window.history.back() goes back to A.

Context:
In the last Front-end Standards meeting, the group suggested to use the History API when it is available, because location.replace() is known to have inconsistent behaviors.
Right now the Router relies on the hashchange event.
We still can't rely only on the History API because we support IE9 and IE9 does not support the History API.

Proposal:

  • Rewrite the router code to use the History API instead of the hashchange event when possible.
  • Abstract the differences between pushState method and hashchange method in OOjs Router.
  • Add a replace history method:
    • Change signature of navigate to support options.replace = true:
      • e.g. router.navigate( path, [options] )
    • Introduce replace method:
      • e.g. router.replace( path )
  • Remove router.back() hack, as this should be possible with the new "history replace" method.

Event Timeline

Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptMay 18 2016, 11:01 PM
JGirault updated the task description. (Show Details)May 18 2016, 11:05 PM

Change 289578 had a related patch set uploaded (by JGirault):
Support replacing the current entry in history.

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

Change 289578 abandoned by Krinkle:
Add an navigation method in OOjs Router that replaces the current entry in document history (instead of creating a new one).

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

Jdforrester-WMF edited projects, added OOjs-Router; removed OOjs.Jul 14 2016, 8:53 PM

The move to Differential has confused me as I've never used the tool before and having 3 workflows along with Gerrit and Github is more than my brain can handle. Is there an open patch somewhere waiting for review or did this stall?

The move to Differential has confused me as I've never used the tool before and having 3 workflows along with Gerrit and Github is more than my brain can handle. Is there an open patch somewhere waiting for review or did this stall?

Current state is that this patch isn't in Diffusion, and doesn't neatly apply (the code it touches has been re-written since).

@Jdforrester-WMF Is this still hosted on Phab? I thought everything was moved back to gerrit? If not, are there any plans to move it?

I'd love to submit some patches so getting it off Phab would be great.

I just noticed that D353: Add an navigation method in OOjs Router that replaces the current entry in document history (instead of creating a new one). is for rMW MediaWiki, directly changing the resources/lib folder. It should actually be for rGOJR OOjs Router?


I've asked @Aklapper for advice on moving the repo.