Skip to content

fix(ion-tabs): preserve route navigation extras when changing tabs#18493

Merged
liamdebeasi merged 12 commits into
ionic-team:masterfrom
jmannau:master
Dec 11, 2019
Merged

fix(ion-tabs): preserve route navigation extras when changing tabs#18493
liamdebeasi merged 12 commits into
ionic-team:masterfrom
jmannau:master

Conversation

@jmannau

@jmannau jmannau commented Jun 9, 2019

Copy link
Copy Markdown
Contributor

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

When using ion-tabs in an angular app, changing tabs doesn't restore the previous route navigation extras, such as Query Params or URL Fragments.

I haven't checked this behaviour in the react or vue distributions.

Issue Number: #18717

What is the new behavior?

This is a bug fix so that when changing tabs, any previous route navigation extras are restored.

Please note, this PR is only for @ionic/angular and not React or Vue projects.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@ionitron-bot ionitron-bot Bot added the package: angular @ionic/angular package label Jun 9, 2019
@jmannau

jmannau commented Jul 26, 2019

Copy link
Copy Markdown
Contributor Author

Hi Ionic Team, you're doing an amazing job and I know are absolutely flat out. I'm just wondering if I can do anything else to help review this pull request so it can be approved and merged? Thanks a million!

@liamdebeasi

Copy link
Copy Markdown
Contributor

Thanks for the PR! We appreciate all the work you put into this.

I think my main concern is changing what getLastUrl returns. This PR changes the return from a string to a RouteView which might be considered a breaking change for users that directly access IonRouterOutlet in their apps.

I am in favor of fixing this issue, but it might have to wait until the next major release of Ionic as we only do breaking changes in major releases. I will post in this thread when I have more to share.

Thanks!

@jmannau

jmannau commented Aug 7, 2019 via email

Copy link
Copy Markdown
Contributor Author

@yannbf

yannbf commented Aug 14, 2019

Copy link
Copy Markdown
Contributor

Thanks for the PR! We appreciate all the work you put into this.

I think my main concern is changing what getLastUrl returns. This PR changes the return from a string to a RouteView which might be considered a breaking change for users that directly access IonRouterOutlet in their apps.

I am in favor of fixing this issue, but it might have to wait until the next major release of Ionic as we only do breaking changes in major releases. I will post in this thread when I have more to share.

Thanks!

@liamdebeasi what about #18740, which fixes the same problem however does not introduce a breaking change?

@liamdebeasi liamdebeasi mentioned this pull request Aug 19, 2019
13 tasks
@liamdebeasi

Copy link
Copy Markdown
Contributor

Sorry for the delay in replying!

What I'm thinking is we can add this change, but add it as a new method and update internal references to use this method. We would still have the old method, but we can mark it as deprecated. This will let us avoid a breaking change while still fixing the issue.

Reinstate getLastUrl to return a string for backwards compatability and add a new method getLastRouteView to return a RouteView complete with route navigation extras (query params and fragments)
@jmannau

jmannau commented Nov 20, 2019

Copy link
Copy Markdown
Contributor Author

Hi @liamdebeasi I made time to look at this again and have restored getLastUrl to return a string for backward compatibility and added a new method getLastRouteView that returns the RouteView. This should remove any breaking changes. The ion-tab directive now uses getLastRouteView internally.

@liamdebeasi

Copy link
Copy Markdown
Contributor

Thanks for making the changes! I found a small bug in the PR. Here are steps to reproduce:

  1. Load Angular test app in src/angular/test/test-app in your browser.
  2. Click "Tabs test".
  3. Click "Go to Page 2 with Query Params".
  4. Click "Tab Two". Notice that the query params/fragments disappear. (This is correct)
  5. Click "Tab One". Notice that the query params/fragments re-appear. (This is correct)
  6. Click the back button in the top left. Notice that the query params/fragments disappear. (This is correct)
  7. Click "Go to Page 2 with Query Params".
  8. Click "Tab Two".
  9. Click "Tab One".
  10. Click "Tab One" again. Notice that you go back a page as in step 6, but the query params/fragments do not disappear. (This part appears to be incorrect).

Other than that, this PR appears to be working properly.

@jmannau

jmannau commented Dec 9, 2019

Copy link
Copy Markdown
Contributor Author

Hi @liamdebeasi I spent some today reviewing this carefully. I have updated the PR to take into account going to the root tab view and respecting the url extras. I have added documentation https://github.com/ionic-team/ionic/pull/18493/files#diff-891ce68da9d3204cb1a1870a225e5350R69 to describe different scenarios wrt tab navigation.

Comment thread angular/src/directives/navigation/ion-router-outlet.ts
Comment thread angular/src/directives/navigation/ion-router-outlet.ts
Comment thread angular/src/directives/navigation/stack-controller.ts
Comment thread angular/src/directives/navigation/ion-router-outlet.ts

@liamdebeasi liamdebeasi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

@liamdebeasi liamdebeasi merged commit 4c8f32f into ionic-team:master Dec 11, 2019
@liamdebeasi

Copy link
Copy Markdown
Contributor

PR has been merged. Thank you!

@JeremyLopez

Copy link
Copy Markdown

PR has been merged. Thank you!

Is there a version of @ionic/angular that contains this fix? I'm running 4.11.10 right now and selecting a new tab does not show this behavior. Or perhaps I'm missing something...

@jmannau

jmannau commented Jul 10, 2020 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular @ionic/angular package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants