Ionic Info
Ionic:
ionic (Ionic CLI) : 4.5.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.19
@angular-devkit/build-angular : 0.10.7
@angular-devkit/schematics : 7.0.7
@angular/cli : 7.0.7
@ionic/angular-toolkit : 1.2.0
System:
NodeJS : v10.13.0 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS Mojave
Describe the Bug
Using Angular's Location.back() has no navigation animation instead of the back navigation animation.
Steps to Reproduce
Steps to reproduce the behavior:
sidemenu Angular stater template. You will need to switch to the _custom-back-button_ branch.npm i.ionic serve.Toggle device toolbar button to simulate a mobile device. From the device dropdown choose an iOS device such as an iPhone X.List.Item 1 to forward navigate to the detail screen for Item 1.Item 2 to forward navigate to the detail screen for Item 2.Item 3 to forward navigate to the detail screen for Item 3.Item 4 to forward navigate to the detail screen for Item 4.ion-back-button but is rather a similarly styled, custom app-back-button component that, when you click it, uses import { Location } from '@angular/common' and does a Location.back().ion-back-button is stated in #15428 (see this comment) and is also mentioned in #16516.Location.back() to go back in the browser history stack.Related Code
A sample application has been provided. See the _Steps to Reproduce_ above.
Expected Behavior
I expected that using Angular's Location.back() to navigate back in the browser's history stack would use the _back_ navigation animation instead of no navigation animation.
Additional Context
See the _Steps to Reproduce_ above for the rationale for using a custom Back button and the related GitHub issues. This behavior change was introduced in Beta 17--perhaps related to fixing #16367.
FWIW, using the Android back button _does_ seem to animate appropriately as does the ion-back-button. The browser back/forward buttons have no navigation animation but that seems appropriate given that it's in a browser context.
Thanks again for all that you do in making a great framework! 馃榾
Related to #15181
+1 can confirm this also
After updating to Beta 19 there is now no longer _any_ type of animation when using Location.back(). The sample project to reproduce the issue has been updated.
I've worked around this by doing the following:
// Provide the back animation.
this.navController.setDirection("back", true, "back");
this.location.back();
You can also use NavController.back(). It similarly does a Location.back() with a navigation animation.
It was helpful to understand more about the role of the v4 NavController vs. the Angular router from the comments in this issue. I felt comfortable using the NavController in this case to get the back animation.
I'm leaving this issue open in case anyone really wants Location.back() by itself to have an animation. If not, it can be closed.
Thanks!
Most helpful comment
I've worked around this by doing the following:
You can also use
NavController.back(). It similarly does aLocation.back()with a navigation animation.It was helpful to understand more about the role of the v4
NavControllervs. the Angular router from the comments in this issue. I felt comfortable using theNavControllerin this case to get the back animation.I'm leaving this issue open in case anyone really wants
Location.back()by itself to have an animation. If not, it can be closed.Thanks!