Files
Sean Perkins 1f06be4a31 fix(nav): root component is mounted with root params (#27676)
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.
2023-06-28 15:27:25 +00:00
..
2022-09-30 12:27:17 -04:00
2023-06-26 13:17:51 +00:00
2023-06-26 13:17:51 +00:00

@ionic/angular

Ionic Angular specific building blocks on top of @ionic/core components.

License

Testing ng-add in ionic

  1. Pull the latest from main
  2. Build ionic/angular: npm run build
  3. Run npm link from ionic/angular/dist directory
  4. Create a blank angular project
ng new add-test
// Say yes to including the router, we need it
cd add-test
  1. To run schematics locally, we need the schematics-cli (once published, this will not be needed)
npm install @angular-devkit/schematics-cli
  1. Link @ionic/angular
npm link @ionic/angular
  1. 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.