bug: router.go with tabs causes undefined references
See original GitHub issuePrerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
- v4.x
- v5.x
- v6.x
Current Behavior
When navigating around the user selects a go back button that takes our user back to a specific page. That page could be -3 pages, -7 or any number of pages. This works fine for a few tries but eventually we receive the Ionic bug. I have the ionBackButton binded to trigger my own go back logic that will trigger route.go(n).
Expected Behavior
Router.go(n) should work regardless of a large, small, or negative number.
Steps to Reproduce
Have a few components and route between them, navigate to a page with tabs and click between the tabs, trigger route.go(-3) to go back a few times using an override like:
document.addEventListener('ionBackButton', this.deviceBackClicked, true);
deviceBackClicked: function (event) {
// event.stopPropagation();
event.stopImmediatePropagation();
this.$router.go(-3)
}
Code Reproduction URL
No response
Ionic Info
Ionic:
Ionic CLI : 6.18.1 (C:\Users\KingSmurf\AppData\Roaming\nvm\v12.22.3\node_modules@ionic\cli) Ionic Framework : @ionic/vue 5.9.1
Capacitor:
Capacitor CLI : 2.5.0 @capacitor/android : 2.5.0 @capacitor/core : 2.5.0 @capacitor/ios : 2.5.0
Utility:
cordova-res : not installed globally native-run : not installed globally
System:
NodeJS : v12.22.3 (C:\Program Files\nodejs\node.exe) npm : 6.14.13 OS : Windows 10
Additional Information
I have a feeling it is related to ionic tabs and have not encountered this problem if I test using pages without tabs.
You can see it is accessing undefined information, crashing the app
Uncaught (in promise) TypeError: Cannot set property ‘mount’ of undefined at Object.unmountLeavingViews (index.esm.js:690) at handlePageTransition (index.esm.js:1095)
Issue Analytics
- State:
- Created 2 years ago
- Comments:33 (26 by maintainers)
Top GitHub Comments
I’m fine with whatever you guys decide. More control for the users is always great.
One idea we are investigating is a “hardware back button strategy API”. This would let developers customize the behavior when going back. Ionic would provide some of the more common behaviors as standalone modules, and developers can choose which one they want to use.