ionic-framework: bug: router.go with tabs causes undefined references
Prerequisites
- 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)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 33 (26 by maintainers)
Commits related to this issue
- fix(vue): switching between tabs and going back resolves to correct route (#25206) resolves #24303 — committed to ionic-team/ionic-framework by liamdebeasi 2 years ago
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.
FYI, I tried to follow these steps in this related issue https://github.com/ionic-team/ionic-framework/issues/24936 and it fixed my issue
We typically use
npm packto build the changes and copy to a test project or we use https://github.com/ionic-team/ionic-framework/blob/main/package.json#L6 to create an installable dev build that others can install.The latter is only available to Ionic Team members since npm access is required, so the easiest is probably to do the following:
npm packto pack the built changes.Here are the instructions for building Vue and Vue Router:
Vue: https://github.com/ionic-team/ionic-framework/tree/main/packages/vue Vue Router: https://github.com/ionic-team/ionic-framework/tree/main/packages/vue-router
For myself, I usually go into the compiled output inside of
node_modulesin my example repo and make changes there to debug quickly. The Vue CLI should detect the changes and refresh the app. I find that to be easier/faster than doingnpm packor a dev build.Thank you, I’m able to reproduce now 👍 After some digging and internal discussion, the underlying cause here seems to be the same as https://github.com/ionic-team/ionic-framework/issues/24332. So, I’m going to close this issue in favor of tracking progress there. I’ll post your reproduction and the steps I found to consistently trigger the errors on that thread.
If the cause turns out to be different, we can re-open this issue and go from there. Thanks for using Ionic!