solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.14k stars 147 forks source link

Undetected location state changes while using browser back/forward buttons #275

Closed oedotme closed 5 months ago

oedotme commented 1 year ago

Describe the bug

Navigation to the same route path with different state is detected using navigate(path, { state: ...}) directly — however when using browser back/forward buttons, the state changes are not detected until the page is refreshed.

Your Example Website or App

https://stackblitz.com/edit/solid-router-back-forward-undetected-state-change

Steps to Reproduce the Bug or Issue

  1. Navigate to the StackBlitz repro link
  2. Wait for the installation to finish and the dev server to start
  3. Important Open the preview in a new tab Open in New Tab
  4. Initial state should be null
  5. Click on Go to about with active true button
  6. You'll see the page updating to /about and the state is {"active": true}
  7. Click on the browser back button
  8. You'll see the home page / and the state is null
  9. Click on Go to home with active false button
  10. You'll see the home page / and the state is {"active":false}
  11. Click on the browser back button
  12. You'll still see the home page / and the state is {"active":false} the unexpected behavior
  13. Refresh the page
  14. You'll see the home page / and the state is null expected at 12. without refresh

Expected behavior

Same steps as above in the reproduction, starting from 11:

  1. Click on the browser back button
  2. See the home page / and the state is null without refreshing the page

Same with the browser forward button

Screenshots or Videos

No response

Platform

Additional context

No response