Skip to content
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

bug: NavController.pop not working in nested outlets #28417

Closed
3 tasks done
ryaa opened this issue Oct 26, 2023 · 3 comments · Fixed by #28421
Closed
3 tasks done

bug: NavController.pop not working in nested outlets #28417

ryaa opened this issue Oct 26, 2023 · 3 comments · Fixed by #28421
Labels
package: angular @ionic/angular package type: bug a confirmed bug report

Comments

@ryaa
Copy link

ryaa commented Oct 26, 2023

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

When the user navigates from the main page to a child page with tabs and then clicks on the button which invokes NavController.pop nothing happens. Please note that it works fine with the ionic 7.4.4 and below and the problem seems to existing on the ionic 7.5.x and above.

To reproduce the problem please open https://stackblitz.com/edit/angular-jddxdk-dpaft4
Please note that everything works as expected with the ionic 7.4.4 - see https://stackblitz.com/edit/angular-jddxdk-ybyyrw

Expected Behavior

NavController.pop must navigate back to the home page

Steps to Reproduce

See above

Code Reproduction URL

https://stackblitz.com/edit/angular-jddxdk-dpaft4

Ionic Info

[WARN] Error loading @ionic/angular package.json: Error
       [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package' is not
       defined by "exports" in
       /Users/alexryltsov/Git/BOSS811-MOBILE/chore-680-update-native-and-non-native-dependencies-to-the-latest-versions/node_modules/@ionic/angular/package.json

Ionic:

   Ionic CLI                     : 6.20.8 (/Users/alexryltsov/.nvm/versions/node/v18.12.0/lib/node_modules/@ionic/cli)
   Ionic Framework               : not installed
   @angular-devkit/build-angular : 16.2.7
   @angular-devkit/schematics    : 16.2.7
   @angular/cli                  : 16.2.7
   @ionic/angular-toolkit        : 10.0.0

Capacitor:

   Capacitor CLI      : 5.5.0
   @capacitor/android : 5.5.0
   @capacitor/core    : 5.5.0
   @capacitor/ios     : 5.5.0

Utility:

   cordova-res                          : not installed globally
   native-run (update available: 1.7.4) : 1.7.3

System:

   NodeJS : v18.12.0 (/Users/alexryltsov/.nvm/versions/node/v18.12.0/bin/node)
   npm    : 9.6.1
   OS     : macOS Unknown

Additional Information

The problem has been discovered after upgrading to the latest ionic framework 7.5.2. Everything worked fine before the upgrade.
Another notes are:

  • if in the child components with tabs I use ion-back-button instead of the custom button to navigate back, everything works fine even with the latest ionic 7.5.2. See my comment in child.component.html
  • if i use navController.back() instead of navController.pop() everything works fine even with the latest ionic 7.5.2. See my comment in child.component.ts
@ionitron-bot ionitron-bot bot added the triage label Oct 26, 2023
@liamdebeasi liamdebeasi self-assigned this Oct 26, 2023
@liamdebeasi liamdebeasi changed the title bug: NavController.pop not working in tabs component (ionic 7.5.x and above) bug: NavController.pop not working in nested outlets Oct 26, 2023
@liamdebeasi liamdebeasi added package: angular @ionic/angular package type: bug a confirmed bug report labels Oct 26, 2023
@ionitron-bot ionitron-bot bot removed the triage label Oct 26, 2023
@liamdebeasi
Copy link
Contributor

liamdebeasi commented Oct 26, 2023

Thanks for the report. Here's a dev build if you are interested in testing a proposed fix: 7.5.3-dev.11698328998.1a79f815

Install Example:

npm install @ionic/angular@7.5.3-dev.11698328998.1a79f815

edit: You may need to test in a local project. StackBlitz sometimes has trouble installing our dev builds.

@liamdebeasi liamdebeasi removed their assignment Oct 26, 2023
github-merge-queue bot pushed a commit that referenced this issue Oct 27, 2023
Issue number: resolves #28417

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

The common `IonRouterOutlet` was trying to inject another common
`IonRouterOutlet` into `parentOutlet`:
https://github.com/ionic-team/ionic-framework/blob/dc94ae01fe9e6c1b570559f0c8308b31e96cc5bf/packages/angular/common/src/directives/navigation/router-outlet.ts#L119
None existed, so this field was `null`.

This is a problem if developers are using the module `IonRouterOutlet`
since parent router outlets will not be currently injected because
Angular is trying to use the common `IonRouterOutlet` not the module
`IonRouterOutlet`:
https://github.com/ionic-team/ionic-framework/blob/main/packages/angular/src/directives/navigation/ion-router-outlet.ts.
The same goes for the standalone `IonRouterOutlet`.

This resulted in things such as `NavController.pop` not working in
nested outlets because the parentOutlet was not defined.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- `IonRouterOutlet` now injects the correct router outlet instance for
`parentOutlet`

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

Dev build: `7.5.3-dev.11698328998.1a79f815`
@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #28421, and a fix will be available in an upcoming release of Ionic Framework. Please feel free to continue testing the dev build. and let me know if you run into any issues.

Copy link

ionitron-bot bot commented Nov 26, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: angular @ionic/angular package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants