Skip to content

Conversation

@pshrmn
Copy link
Contributor

@pshrmn pshrmn commented Apr 1, 2019

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

The browser preview starts with an empty history array in state and a historyPosition of -1. After initializing, the URL listener dispatches a REPLACE, which adds an entry to the preview's history array, but the historyPosition is still -1. This causes two incorrect behaviors: 1) the preview thinks that it can go forward immediately and 2) the preview can never return to the initial location.

(I made the REPLACE change in #1158, so I suppose that this bug is my fault. I'm not sure how I didn't notice the issue until now, but I didn't spot any other changes, so it must have existed since that PR.)

What is the new behavior?

By starting with the historyPosition of 0, the preview 1) cannot go forward immediately and 2) can return to the initial location.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table
@CompuIves
Copy link
Member

This is great! Thanks a lot for fixing this.

@CompuIves CompuIves merged commit 862d2a8 into codesandbox:master Apr 1, 2019
@pshrmn pshrmn deleted the zero-index branch April 1, 2019 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants