-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix(vue-router): wrong location histories when replace #24409
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
fix(vue-router): wrong location histories when replace #24409
Conversation
The blank page is a different bug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! We appreciate your contribution to Ionic. Before this gets merged, could you please write a test for this?
In my opinion it looks like your change would just ignore another lower level problem. const last = () => locationHistory[locationHistory.length - 1]; The last would still reference the wrong viewItem? Shoulnd't the last item return the last item correctly, and if not was the one that is missing not de-mounted properly? I'm currently tracking a similar bug where the prevRouteLastPathname points to the wrong component because something was replaced and not demounted. Also doesn't help that none of the types.ts properties do not have comments so it is hard to tell what is used for what / why. Like why would you need to know the previous routes last path name, which in some cases could be 2 routes ago if something was replaced. You would think that calling replace should demount the last item. You can see a similar issue here, the circle in red is the page I navigated to by 'replace' but the current page is not demounted because prevRouteLastPathname is a mess The IonRouterOutlet.ts/router.ts/locationHistory.ts is a mess. Should be heavily refactored/commented. In some cases multiple places can trigger a mount on a component, some things are async and await and others are not awaited properly. Maybe I am wrong but it is hard to tell anything with a codebase that is not commented. |
I took a quick look and noticed that the Regarding location history, the location history is our way of keeping track of navigation items separate from the browser. There are a few reasons for this:
Definitely agree that the routing files could do with more commenting, though I'm not sure a refactor would solve much. The routing integrations are pretty robust, but it's mainly these edge cases that we are still trying to work through. I'll update here/on the issue thread when I have a fix for folks to test. Thanks! |
All the classes purposes make sense but as far as how the code is tangled, seems some responsibilities should be moved away/restructured. Or possibly different patterns implemented for readability/less bugs, like fail first, or events. I'm quite deep in debugging the #23873 (comment) but I am not sure if some of the stuff I am seeing are bugs. Like we were going from our /settings page to /settings/about page and it was trigger this:
Where it is a one-off for mounting views, and in this case it didn't do anything. The mounting was still performed by:
Why have two places mount code? Also seems demounting is handled in the viewStacks code(sometimes), why not move mounting there too? I know the mountIntermediaryViews was commented but it still makes no sense. For the entire block of code:
Why would the leaving view not be mounted, if the user keeps navigating forward, don't demount? Like /settings -> /settings/a -> /settings/a/b? Then if the user starts using the ion-back-button would these be 'demounted'? Is there a place we can ask code questions? Why do you inline demount the leaving view but not the enteringViewItem that uses ' viewStacks.unmountLeavingViews', shouldn't the leavingViewItem be passed to 'viewStacks.unmountLeavingViews'? viewStacks.mountEnteringViews does not even exist. I would imagine the demounting should be performed when the item is removed from the locationHistory stack, not from the IonRouterOutlet code. Now things can get messy on what is mounted/not mounted/in the location stack/not in the location stack. |
I can understand the desire to get these lingering questions answered, but I'd prefer the focus of this thread be kept on the PR and the code changes contained within the PR. For other general questions about Ionic, you can ask them on the Ionic Forums. |
My only questions would be code specific, which it looks like you are responsible for 99% of. Perhaps I can make a pull request and ask questions/add your answers as comments to commit to the codebase? setupViewItem should still just create the view item and viewStacks should mount it, then setupViewItem can continue with the transition. There shouldn't be mounting code in 10 places. |
Ha, I want to know what after in PR's? Continue to add tests? Or trash? I found at least four problems in the router.
Is the fourth problem the same as the second problem? or the same as the third problem? This PR only can solve the fourth problem. |
Stepping in here. We expect everyone involved to be professional and respectful. Locking this PR for now. EDIT: I had incorrectly assumed bad intent from @yoyo930021. That was a mistake on my part. I have updated the comment to remove their name. |
Closing this in favor of PR #24433. Appreciate the time that everyone has put into this and look forward to constructive collaboration on that PR and future works. Thanks all & happy holidays 🎉 |
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
The tab page will not render with enteringViewItem === leavingViewItem
Issue Number: #24226
What is the new behavior?
The location histories will correct, so enteringViewItem !== leavingViewItem.
The tab page will render.
Does this introduce a breaking change?
Other information
Fixed #24226
Do I need to add test ?