remix-run / react-router

Declarative routing for React
https://reactrouter.com
MIT License
53.13k stars 10.31k forks source link

Firefox rendering wrong URL #837

Closed agundermann closed 9 years ago

agundermann commented 9 years ago

Steps to reproduce:

  1. On Firefox, go to http://react-router-mega-demo.herokuapp.com/
  2. Click any contact name
  3. Focus URL bar, press enter
  4. Click back button

Expected: URL path and content match up (either root or contact) Actual: URL path is '/', but contact is rendered

Not sure about other browsers.

Apparently, this is due to browser back forward caching which can be disabled with

window.unload = function() { }

Is this worth documenting or even fixing?

julen commented 9 years ago

I'm on Firefox and cannot reproduce this issue.

BerkeleyTrue commented 9 years ago

Working fine for me on FF 35.0.1

agundermann commented 9 years ago

That's weird. I tried it on several machines (all windows though) and all of them were affected.

Here's a gif: http://i.giphy.com/AxVvjHQiDubQvpgcJW.gif

Are you sure that doesn't happen on your machines?

BerkeleyTrue commented 9 years ago

Its an illusive bugger, but check out this out.

Just upgraded to FF 36 on OSX Yosemite. rr-ffbug

but FF dev ed 37.0a2 rr-ffbug-2

julen commented 9 years ago

37.0a2 here on OS X as well, but all working fine.

ryanflorence commented 9 years ago

@taurose I can't reproduce this either, let me know if you track it down, closing until then.

agundermann commented 9 years ago

Still an issue (FF 38.0.5, Windows 8). Not sure why you can't reproduce this. Maybe the URL bar thing isn't consistent across platforms. Try this:

  1. On Firefox, go to http://react-router-mega-demo.herokuapp.com/
  2. Click any contact
  3. Click Ryan Florence at the top to leave the app
  4. Go two entries back at once by right clicking the back button

You should see the contact rendered, but the URL of the index page.

As far as I can tell BFCache is the problem. It caches the whole DOM of the app at the state it was left, but then restores it even if we reenter at a different URL. And popstate/hashchange doesn't fire, so the app can't catch up.

As explained in the link above, I think we'd have to listen to some extra event. We can also suppress the cache, but would be nice to take advantage of it.

ryanflorence commented 9 years ago

ping @taurose, do you know if this is resolved on master?

ryanflorence commented 9 years ago

closing, I think history fixed this stuff, please reopen if I'm wrong.

agundermann commented 9 years ago

Not yet, but there's an open issue https://github.com/rackt/history/issues/34