Ionic-framework: [4.0.0-rc.1] Modal shows up when not presented

Created on 14 Jan 2019  路  5Comments  路  Source: ionic-team/ionic-framework

Bug Report

Ionic version:
[x] 4.x

Current behavior:
Modal page shows up even when not presented.

Expected behavior:
Modal page should only show up when presented.

Steps to reproduce:
Here's a repo: https://github.com/YDrogen/capacitor-issue-android-modal (Don't mind the repo name - bug might not come from Capacitor)

  • ng serve
  • Go to the browser and click on OPEN MODAL - Ionic asks to add ModalPage to entryComponents
  • Uncomment entryComponents: [ModalPage] from app/home/home.module.ts
  • Go back to the browser and click on OPEN MODAL - It works!
  • Use Capacitor for Android to compile and starts it in debug mode - Capacitor logs: Component ModalPage is not part of any NgModule or the module has not been imported into your module.
  • Uncomment ModalPageModule from app/home/home.module.ts
  • If you go back to the browser, the modal always shows up. Same problem if you rebuild and recompile for Android

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.3.1 (C:\Users\YDrogen\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.0.0-rc.1
   @angular-devkit/build-angular : 0.11.4
   @angular-devkit/schematics    : 7.1.4
   @angular/cli                  : 7.1.4
   @ionic/angular-toolkit        : 1.2.2

System:

   NodeJS : v8.9.1 (C:\Program Files\nodejs\node.exe)
   npm    : 6.5.0
   OS     : Windows 10
triage

Most helpful comment

@YDrogen modal.module.ts can't have router.
https://github.com/YDrogen/capacitor-issue-android-modal/blob/master/src/app/modal/modal.module.ts#L10-L15

You should remove RouterModule.forChild(routes) .

All 5 comments

@YDrogen modal.module.ts can't have router.
https://github.com/YDrogen/capacitor-issue-android-modal/blob/master/src/app/modal/modal.module.ts#L10-L15

You should remove RouterModule.forChild(routes) .

Yep, because you are overwriting the forChild Routes of your home.page.module.
Both Modules have a default route to path: ''.

Thanks guys for finding the issue :) So this issue will be closed

Thanks! Been on this issue for a while, I didn't knew that it would override, I just used ionic generate for these modals and didn't found any documentation about this!
Sorry for the inconvenience!

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.

Was this page helpful?
0 / 5 - 0 ratings