question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: router.go with tabs causes undefined references

See original GitHub issue

Prerequisites

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.

image

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:closed
  • Created 2 years ago
  • Comments:33 (26 by maintainers)

github_iconTop GitHub Comments

1reaction
tigohenryschultzcommented, May 3, 2022

I’m fine with whatever you guys decide. More control for the users is always great.

1reaction
liamdebeasicommented, May 3, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic nested routes and tabs not working as expected
Hi, We have an application with 4 tabs each having nested routes. ... issue: bug: router.go with tabs causes undefined references · Issue ......
Read more >
Uncaught (in promise) undefined - Vue-router - Stack Overflow
I think the issue is being caused by the re-reoute. If the user does not have page_access 1, it then routes to /holidays....
Read more >
Fixing the PHP Error 'Undefined Index - Kayako Classic Support
Solution · Log in to the admin control panel. · From the Home tab, click Email Parser, then click Rules. · Select the...
Read more >
SOLVED: Undefined Reference to function (STM32 CubeIDE)
A quick solution to error "undefined reference to function" in STM32 CubeIDE or any other STM32 development IDE.
Read more >
History.pushState() - Web APIs | MDN
If this parameter isn't specified, it's set to the document's current URL. Return value. None ( undefined ). Description. In a sense, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found