Skip to content
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

change nav type to redirect when doing live navigation #3538

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/js/phoenix_live_view/live_socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,10 @@ export default class LiveSocket {
this.withPageLoading({to: href, kind: "redirect"}, done => {
this.replaceMain(href, flash, (linkRef) => {
if(linkRef === this.linkRef){
// we must change the type of the current history state as well
// to ensure we also do a redirect type navigation when we navigate back;
// otherwise we run into https://github.com/phoenixframework/phoenix_live_view/issues/3536
if(history.state?.type === "patch"){ Browser.updateCurrentState((state) => ({...state, type: "redirect"})) }
Browser.pushState(linkState, {type: "redirect", id: this.main.id, scroll: scroll}, href)
DOM.dispatchEvent(window, "phx:navigate", {detail: {href, patch: false, pop: false}})
this.registerNewLocation(window.location)
Expand Down
Loading