Prequisites
Ionic Framework Version
Current Behavior
Navigating using router.go(n) with an n value less than -1, Ionic React does not show the correct view because it always assumes a delta of 1 or -1.
Expected Behavior
I would expect Ionic React to show the correct view regardless of the delta value.
Steps to Reproduce
- Start with one page and push 2 IonPages to navigation stack via navigation.push()
- Let the 3rd page navigate back ("history stack pop") to the first page via navigation.go(-2)
- Observe that react's router does produce the proper URL (path) of the first page. But also observe that the the previous route (page) in the history stack is rendered, not the very first page which belongs to that path.
Code Reproduction URL
https://github.com/larsblumberg/ionic-back-navigation-broken
Ionic Info
No response
Additional Information
This is a continuation of #22563.
At the time of writing, there does not seem to be a straightforward way to implement this. The fix for this in Ionic Vue relied on Vue Router exposing a delta value as well as a custom state object in window.history.state that let us track which view to show. React Router does not expose this kind of information according to remix-run/history#36 (comment) and remix-run/history#334 (comment).
One option is we could build this position tracking into Ionic React ourselves, but I am a bit hesitant to start altering window.history.state especially when React Router already manages the state for us.
Prequisites
Ionic Framework Version
Current Behavior
Navigating using
router.go(n)with annvalue less than-1, Ionic React does not show the correct view because it always assumes a delta of1or-1.Expected Behavior
I would expect Ionic React to show the correct view regardless of the delta value.
Steps to Reproduce
Code Reproduction URL
https://github.com/larsblumberg/ionic-back-navigation-broken
Ionic Info
No response
Additional Information
This is a continuation of #22563.
At the time of writing, there does not seem to be a straightforward way to implement this. The fix for this in Ionic Vue relied on Vue Router exposing a delta value as well as a custom state object in
window.history.statethat let us track which view to show. React Router does not expose this kind of information according to remix-run/history#36 (comment) and remix-run/history#334 (comment).One option is we could build this position tracking into Ionic React ourselves, but I am a bit hesitant to start altering
window.history.stateespecially when React Router already manages the state for us.