Giter Site home page Giter Site logo

Comments (8)

michalkvasnicak avatar michalkvasnicak commented on May 3, 2024

Maybe BrowserHistory and HashHistory should be "children" of MemoryHistory?

from history.

mjackson avatar mjackson commented on May 3, 2024

As of right now even MemoryHistory isn't able to pull this off. What we're missing is a way to get the "current" index after a POP.

from history.

michalkvasnicak avatar michalkvasnicak commented on May 3, 2024

I think we need to track a previous location in go() and pushState() calls then pass the previous location to cancelTransition() call together with location we are on. Something like cancelTransition(previous, current).

We are now tracking pendingLocation in transitionTo() but I think we can't use it as previous location to cancelTransition() call because previous and current will be always the same.

In the MemoryHistory it doesn't matter because it isn't listening to POP events and can be modified only using the go(), goBack(), goForward(), replaceState() and pushState() methods. In this case transition will wait for confirmation.

But maybe I am wrong.

from history.

michalkvasnicak avatar michalkvasnicak commented on May 3, 2024

Another question is, what will happen if user won't use window.confirm but some sort of a modal window that will be nonblocking and pushes back button during a confirmation of previous transition?

  1. A
  2. B
  3. C
  4. go back
  5. I am on the C but app is asking me for a confirmation and I push back button again
  6. I am on B and I confirm previous confirmation and I will be redirected to C?

from history.

michalkvasnicak avatar michalkvasnicak commented on May 3, 2024

Maybe we should not call transitionTo() if there is any pending transition?

from history.

michalkvasnicak avatar michalkvasnicak commented on May 3, 2024

Im DOM histories we should track previous and current location in onpopstate/hashchange handlers and pushState() only.

from history.

michalkvasnicak avatar michalkvasnicak commented on May 3, 2024

@mjackson what do you think about this?

from history.

mjackson avatar mjackson commented on May 3, 2024

I think we need to track a previous location in go() and pushState() calls

This will not work immediately after a refresh. Imagine the user comes to the site, navigates from A => B => C and then refreshes the page. At that point, we'd like to know that we have a current value of 2 (assuming a 0-based index).

what will happen if user won't use window.confirm but some sort of a modal window that will be nonblocking and pushes back button during a confirmation of previous transition?

Currently, there is an invariant that prevents this from happening. However, in the situation you described this obviously isn't ideal. I think the right thing to do in that case would be for the user to detect the second transition, remove the modal, and proceed with the latter transition.

from history.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.