bug: [Ionic v4] query params are getting lost when navigating between tabs
See original GitHub issueBug Report
Query params are getting lost when navigating back and forth between tabs when using the ion-tabs buttons.
Current behavior: When navigating between tabs and one of the views of the tabs has query params in its URL (http://www.examplepage.com/tab1?key=value), the query params are lost when navigating back to that particular Tab.
Example:
- Tab A has a view with query params in its URL
- I click on the ion-tab-button to navigate to Tab B.
- I navigate back by using the ion-tabs to Tab A.
- And then the query params for Tab A are lost (http://www.examplepage.com/tab1?key=value -> http://www.examplepage.com/tab1).
Expected behavior: Following the example above, I will expect the query params to be preserved when navigating back to the latest active view on Tab A.
Related code:
I did some investigation and I did notice that the Angular Router is properly saving the query params under the property savedExtras
but the Ionic IonRouterOutlet API only refers to the
URL without taking into the account the query params, like it can be checked in the code below from the IonRouterOutlet class.
/**
* Returns the URL of the active page of each stack.
*/
getLastUrl(stackId?: string): string | undefined {
const active = this.stackCtrl.getLastUrl(stackId);
return active ? active.url : undefined;
}
I am not sure if this is the expected behavior or if the queryParams needs to be considered when getting the last Url.
Ionic info:
Ionic:
ionic (Ionic CLI) : 4.2.1
System:
NodeJS : v10.9.0
npm : 6.7.0
OS : macOS
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Thanks for the issue! This bug has been resolved via https://github.com/ionic-team/ionic/pull/18493 and will be available in an upcoming release of Ionic Framework.
@liamdebeasi I see there are two PRs that intend to fix this issue: #18740 and #18493. Is it possible to have someone from Ionic to review them?
Thanks!