-
Notifications
You must be signed in to change notification settings - Fork 951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Browser Back Button Fails to Update Content After Navigation in Phoenix LiveView #3508
Comments
SteffenDE
added a commit
that referenced
this issue
Jan 10, 2025
Relates to: #3529 `replaceRootHistory` was initially added by @josevalim in 36edb48, but lost its purpose after less than three months with 04aaedc removing the only call that would actually set `root: true` in the history state. Me not knowing what `root: true` is supposed to do reused replaceRootHistory in #3335, reintroducing the case where `root: true`` is set in the history state. While #3335 was reverted later due to issues (#3508), I reworked the back/forward navigation problem in #3539, which again used `replaceRootHistory`. As `root: true` would now be set in the history, we'd call `replaceRootHistory` on live navigation. The problem is that it was setting `type: "patch"` in the history, which leads to LiveView assuming that it can patch when navigating using popstate, while the actual navigation was `type: "navigate"`. After looking into it, I don't really see a reason for replaceRootHistory to exist any more.
SteffenDE
added a commit
that referenced
this issue
Jan 26, 2025
Relates to: #3529 `replaceRootHistory` was initially added by @josevalim in 36edb48, but lost its purpose after less than three months with 04aaedc removing the only call that would actually set `root: true` in the history state. Me not knowing what `root: true` is supposed to do reused replaceRootHistory in #3335, reintroducing the case where `root: true`` is set in the history state. While #3335 was reverted later due to issues (#3508), I reworked the back/forward navigation problem in #3539, which again used `replaceRootHistory`. As `root: true` would now be set in the history, we'd call `replaceRootHistory` on live navigation. The problem is that it was setting `type: "patch"` in the history, which leads to LiveView assuming that it can patch when navigating using popstate, while the actual navigation was `type: "navigate"`. After looking into it, I don't really see a reason for replaceRootHistory to exist any more.
SteffenDE
added a commit
that referenced
this issue
Jan 26, 2025
* remove replaceRootHistory Relates to: #3529 `replaceRootHistory` was initially added by @josevalim in 36edb48, but lost its purpose after less than three months with 04aaedc removing the only call that would actually set `root: true` in the history state. Me not knowing what `root: true` is supposed to do reused replaceRootHistory in #3335, reintroducing the case where `root: true`` is set in the history state. While #3335 was reverted later due to issues (#3508), I reworked the back/forward navigation problem in #3539, which again used `replaceRootHistory`. As `root: true` would now be set in the history, we'd call `replaceRootHistory` on live navigation. The problem is that it was setting `type: "patch"` in the history, which leads to LiveView assuming that it can patch when navigating using popstate, while the actual navigation was `type: "navigate"`. After looking into it, I don't really see a reason for replaceRootHistory to exist any more. * add e2e test for #3529 * update changelog
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
Actual behavior
I reproduced the issue in a simple Phoenix and LiveView project, which I’ll share the link for below.
The issue is as follows: if I set up a router with the path
/doc/:id
to display content based on a given ID (either from the database or memory), and then navigate to a different page using thenavigate
property of the link component, everything seems to work initially. However, when I click the browser’s back button, the URL and page title change correctly, but the content itself does not update.Video:
LiveViewBrowserBack.mov
Reproduced project link
Please Go to
http://localhost:4000/doc/1
link and click on (Click here to navigate Page B)http://localhost:4000/doc/2
.Extra test
For extra and real case I created a simple static blog that you can see in this link:
Please click on
Build a Static Site in Elixir Under 5 Minutes with Phoenix Components
and backSimple code:
And router:
By the way, if I navigate to page 1 again it has no problem, the only problem is from browser back button and it sends a
handle_params
request, I demonstrated this issue in the video above.Based on speaking with @SteffenDE in slack it is not related to #3482 PR.
Thank you in advance. I hope I didn't make any mistakes or waste your time.
The text was updated successfully, but these errors were encountered: