mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00

Issue number: Resolves #27146 --------- <!-- 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. --> When an `ion-nav` is presented multiple times in an overlay, the user's `root` component will attempt to be attached twice. This results in the view being mounted without the `rootParams` being defined, causing an exception in a user's application. This behavior occurs due to the `root` watch callback firing twice. The second time the `ion-nav` is presented in an overlay, the watch callback will execute _before_ `componentDidLoad` fires. This results in the watch callback firing twice, once from the underlying change detection and the second time from [manually calling the function](https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/nav/nav.tsx#L115) from `componentDidLoad`. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - `ion-nav` includes a new flag to track when `componentDidLoad` executes. This allows us to prevent the behavior of the `rootChanged` callback from happening when the component has not loaded. - `ion-nav` consistently attaches the `rootParams` to the `root` component. ## 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.0.15-dev.11687924603.10a1e477`. ### How to test You can install against the reproduction app in the linked issue to verify the behavior before and after. - Before, the app will throw an exception when presenting the modal the second time. - After, the app will not throw an exception when presenting the modal the second time. Information that you fill out on the main screen form will be rendered inside the modal content.
@ionic/angular
Ionic Angular specific building blocks on top of @ionic/core components.
Related
License
Testing ng-add in ionic
- Pull the latest from
main
- Build ionic/angular:
npm run build
- Run
npm link
fromionic/angular/dist
directory - Create a blank angular project
ng new add-test
// Say yes to including the router, we need it
cd add-test
- To run schematics locally, we need the schematics-cli (once published, this will not be needed)
npm install @angular-devkit/schematics-cli
- Link
@ionic/angular
npm link @ionic/angular
- Run the local copy of the ng-add schematic
$ npx schematics @ionic/angular:ng-add
You'll now be able to add ionic components to a vanilla Angular app setup.