change nav type to redirect when doing live navigation #3538
+4
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3536.
Browser history API strikes back (again). Because live navigation shares the id of the view between live navigations, the following scenario could happen:
In step 6, the user is still on page 2, but LiveView would try to patch the page instead of performing a live navigation. This is only a problem if the two pages use the same underlying LiveView module, otherwise the patch request would fallback to a navigation.
This commit "fixes" this by modifying the current history entry at step 2 to
redirect
before pushing the new state. This way, LiveView does a live navigation when popping the state in step 6.The underlying problem is that we cannot differentiate a forward from a backward navigation when handling a popstate. If we could, we'd be able to separately store the backwards and forwards navigation type. The current approach will also do a live navigation when navigating forward again, therefore if a user went back in history to step 1 and pressed forward, we now do a live navigation instead of a patch, therefore potentially losing state.
See also #3513 (comment).