-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: router.go with tabs causes undefined references #24303
Comments
Thanks for the report. Could you please create an Ionic starter app that reproduces the issue and post a link to the repo? Aside: this may be similar to #22563. |
Thanks for the issue! This issue has been labeled as Please reproduce this issue in an Ionic starter application and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed. If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue. For a guide on how to create a good reproduction, see our Contributing Guide. |
Reproduced here: https://github.com/tigohenryschultz/router-undefined-reference To reproduce use the navigation buttons to navigate to the tabs pages, click between the tabs and use the 'GO BACK PAGE 1' or 'GO BACK PAGE 3' button. Sometimes you have to do this a few times, but shouldn't take more than a few minutes to see the attached undefined reference bug in the router code. We are keeping track of the navigation stack to see how many times we need to go back, so the router.go delta can be -3, -5, -10. Eventually youll see this bug: |
I'm unable to replicate the error using that repo and following your instructions. Would you be able to give more specific steps to replicate? A recording of your own might also help. |
Sure @amandaesmith3 , give me a few minutes |
The main way to reproduce it is to keep navigating back to the tabs, click a few tabs, then click 'GO BACK PAGE 1' or 'GO BACK PAGE 3' video-1638564768.mp4These are the consoles errors I received: Once you see the log: index.esm.js?bec5:690 Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'mount') Usually the interface will then lock up, as seen in this video: video-1638564905.mp4 |
Thank you, I'm able to reproduce now 👍 After some digging and internal discussion, the underlying cause here seems to be the same as #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! |
Reopening as per #24332 (comment) |
The consistent reproduction steps I found:
|
@amandaesmith3 When you want to debug these sample projects, how do you install the ionic-framework codebase locally for debugging/fixing? I would happily look into this bug and submit a pull request but I was unable to install the ionic-framework locally using
Kept getting one eslint/webpack problem after another. Is there a guide on installing locally for debugging? |
We have a contributing guide here: https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-a-pull-request |
Those instructions are for testing changes in the core, not in my code base. I was talking about installing the vue-router locally to https://github.com/tigohenryschultz/router-undefined-reference How else would you know if you fixed the bug if you didn't install the vue-router codebase locally to a project? Essential this project: https://github.com/tigohenryschultz/router-undefined-reference would reference the local copy of vue-router instead of the npmjs published one, so I can test code changes in real-time. Is this not how you guys fix bugs from projects submitted in tickets? |
We typically use The latter is only available to Ionic Team members since npm access is required, so the easiest is probably to do the following:
Here are the instructions for building Vue and Vue Router: Vue: https://github.com/ionic-team/ionic-framework/tree/main/packages/vue For myself, I usually go into the compiled output inside of |
Will give that a go. For other npm packages we normally we are able to install development npm packages locally like: npm i c:\repos\ionic-framework\packages\vue-router But eslint/webpack is not happy with something in the vue-router packages. This is how we are normally able to work on our npmjs packages, we can change them in the project directly and since npm is referencing the folder as a symbolic link it can watch/rebuild it when necessary instead of writing code in the compiled output. I tried tweaking stuff in your vue-router package but wasn't sure what the issue was, I think its something in the package.json causing issues with eslint/webpack. Would be nice to figure that problem out one day, will make debugging a lot smoother. But I'll give your steps a go and see what I can dig up, thanks! |
Interesting, what ESLint/Webpack errors were you getting? |
I created this forum post here: Seems like it was missing some eslintConfig properties to the package.json in @ionic/vue-router and then in our ionic app we had to make other changes but kept running into different errors. Here is a picture of one of our npmjs packages package.json that we are able to install locally like: npm i c:\repos\tigoapps\packages\tigobuild This way I can write code/debug directly here and the watcher can rebuild in realtime from this folder. |
Spent a little time researching the two errors being thrown, here's what I've found so far: While following Amanda's replication steps, when performing step 6 (Go back to Page 3), the look-up for the entering view does not return a result.
where routeInfo is: {
delta: -1,
id: "3",
lastPathname: "/tabs/tab1",
params: {},
pathname: "/page3",
position: 15,
prevRouteLastPathname: "/page1",
pushedByRoute: "/page2",
routerAction: "pop",
routerDirection: "back",
search: ""
} and The second time that it is successful, the routeInfo is mostly the same, with the addition of: The second exception that occurs with step 9 (Going back to Page 1), is a result of the delta being |
If |
I'm facing the exact same issue. Navigating back and forth and jumping between tabs causes Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'mount') and Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'classList') |
Thanks for the issue. Can everyone try the following dev build, and let me know if it resolves the issue?
A couple notes:
After following the steps in #24303 (comment) up to step 5, clicking "Go back Page 3" performs So when you do Page 3 --> Tab 1 --> Tab 2 --> Tab 1, the history stack looks something like this:
This is aligned with mobile tabs behavior. To compare, open a tabbed application on an Android phone and do Tab 1 --> Tab 2 --> Tab 1. Pressing the hardware back button should bring you back to Tab 2. For this particular app, it looks like it should be performing |
FYI, I tried to follow these steps in this related issue #24936 and it fixed my issue |
Hi, with this build i'm still getting Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'mount') |
@Jannik-KJ It's hard to say what the issue may be without a reproduction. Can you provide a GitHub repo I can use to reproduce the issue? |
Also, it may be better to start a separate thread. I recall mentioning this in #25017 (comment). It's possible that the issue you are running into is a different issue. |
Thanks for the issue. This has been resolved via #25206, and a fix will be available in an upcoming release of Ionic Framework. Please feel free to continue testing and let me know if you run into any issues. |
@liamdebeasi I have created a clean project with a single child route and was able to reproduce it. |
I noticed that the tab history stacks indefinitely now but in my limited testing I did not see any issue. If a user clicks between two tabs 100 times they will need to click back 100 times, to my understanding that is not designed behavior as the tab history stack is tracked for each unique outlet/tab. |
So the main thing here we need to be concerned about is the hardware back button on Android (aka going back multiple times as you noted). The browser back button also applies, but I am going to reference only the hardware back button for this example. Unfortunately, Android apps do not have a consistent tabs interaction pattern. There are a few patterns we could adopt: Gmail Pattern: Pressing the hardware back button on the root of a tab jumps you back to the initial tab. Example: Mail --> Chat --> Spaces --> Meet. Pressing the hardware back button once will take you from Meet to Mail. Notice that we never go back to Chat or Spaces. Spotify Pattern: Pressing the hardware back button on the root of a tab jumps you back to the previous tab you were on. Example: Home --> Search --> Your Library. First hardware back button press: You are taken back to Search. In this example, you can switch between Home and Search 100 times. You will need to press the hardware back button 100 times as well. This is the pattern Ionic follows as it is easiest to implement/reason about. Note: There is a bug where pushing child views within tabs causes this to not work as intended. We are tracking this in #25213. Google Play Pattern: Pressing the hardware back button on the root of a tab jumps you back to the previous tab you were on. However, it will never bring you back to the same tab twice. Example: Games --> Apps --> Movies & TV --> Apps. First hardware back button press: You are taken back to Movies & TV. Google Drive Pattern: Pressing the hardware back button on the root of a tab closes the app. Example: Home --> Starred --> Shared --> Files Pressing the hardware back button on the Files tab just closes the app. Honestly what's most concerning here is there are three Google made apps that each have drastically different tabs behaviors. As a result, it's hard to say which behavior is "correct". As I mentioned, we currently implement the Spotify pattern, but this is something worth discussing with the team as we seek to clean up our routing integration. |
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. |
I'm fine with whatever you guys decide. More control for the users is always great. |
Thanks for pointing this behavior by the way -- I did not know that our behavior was not the only tabs behavior until I dug into this a bit more. |
I'm receiving similar issue reports from Sentry, but I'm using React (@ionic/react + @ionic/react-router 6.1.6) Apparently this happens when users switches tabs ~ 3 times within 2 seconds. I'm not able to tell if user was pressing hardware back button or using buttons to switch tabs. I was not able to reproduce it either in browser nor in emulator. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Ionic Framework Version
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:
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)
The text was updated successfully, but these errors were encountered: