ionic-team / ionic-team/ionic-framework
bug: The navigation direction is preserved after calling any of the NavController's navigate methods while being on the same route
- Vorherrschende Sprache
- TypeScript
- Sterne
- 52.7k
- Forks
- 13.3k
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 51
Beschreibung
### Prerequisites
- [x] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#creating-an-issue).
- [x] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [x] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already report this problem, without success.
### Ionic Framework Version
v7.x
### Current Behavior
If I'm already on a given page/route (e.g. "/home"), and I call `navController.navigateRoot('/home')`, the root direction is not "used" and it's preserved for any future navigation I use. So if after that navigation, I just click on any link using a standard routerLink, that navigation is done with a root direction instead of the default "forward".
### Expected Behavior
When the `navController.navigateRoot('/home')` finishes, the root direction should be changed back to default, regardless if the navigation really happened or not (depending on whether you were already on that page). Not reverting the direction to the default value is very dangerous and causes very weird bugs, as your next navigation just uses the previously root direction without you wanting that.
### Steps to Reproduce
1. Go to any route (e.g. '/home').
2. Call `navController.navigateRoot('/home')`
3. Do any other standard navigation by clicking on a routerLink element or using a normal `router.navigateByUrl('/another-page')` method to a different route.
4. Observe how the last navigation is done using root direction. This is most easily noticeable if you have an ion-back-button on the new page and it just doesn't show.
### Code Reproduction URL
https://stackblitz.com/edit/lwufjbgw-pht97uge?file=src%2Fapp%2Fexample.component.html
### Ionic Info
Ionic:
Ionic CLI : 7.2.0 (C:\Users\XXX\AppData\Roaming\nvm\v20.18.0\node_modules\@ionic\cli)
Ionic Framework : @ionic/angular 8.6.3
@angular-devkit/build-angular : 18.2.11
@angular-devkit/schematics : 18.2.11
@angular/cli : 18.2.11
@ionic/angular-toolkit : 11.0.1
Capacitor:
Capacitor CLI : 6.1.2
@capacitor/android : 6.1.2
@capacitor/core : 6.1.2
@capacitor/ios : 6.1.2
Utility:
cordova-res : not installed globally
native-run : 2.0.1
System:
NodeJS : v20.18.0 (C:\Program Files\nodejs\node.exe)
npm : 10.8.2
OS : Windows 10
### Additional Information
I know I can theoretically check whether I'm on the route already and avoid calling any of the navigate methods if I'm already there, or call `navController.setDirection('forward')` after calling `navController.navigateRoot(X)`, but I think that that should be handled at the framework level, as the workarounds are weird and not intuitive.
I coded the example in the Stackblitz link, but for some reason, routerLink wasn't working for me at all in that environment. If someone has an idea why, the reproduction example should otherwise fully work.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.