differentiate between back and forward navigation #3539
+148
−8
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.
Relates to #3513.
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. Also, we have an unnecessary live navigation instead of a patch at step 5.
To fix this, we now differentiate if we are navigation backwards of forwards and store the corresponding
backType
in the history state to do the correct type of navigation on popState, which was already mentioned as an idea in #3513.Finally, we can also prevent the unnecessary remount when navigating all the way back properly (see #3335).