question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: angular devkit, production build causing issues with modalController.dismiss

See original GitHub issue

Prequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

On Android device / simulator, when a modal that contains an ion-slide in its ion-content is opened, it can’t be closed. It doesn’t seem to affect iOS nor web platforms.

https://user-images.githubusercontent.com/216573/128859538-d7044aec-31d7-45a7-b1e2-4ce1bcff3fac.mov

Expected Behavior

Modal should close as expected

Steps to Reproduce

  1. Clone this project https://github.com/JumBay/ionic5-modal-issue.
  2. npm i
  3. run npm run run:android

OR

  1. Create a new @ionic/angular blank project
  2. Upgrade deps (@ionic/angular and @angular/XXX deps)
  3. Replace home.page.ts’ content by:
import { Component } from '@angular/core';
import { ModalController } from '@ionic/angular';

@Component({
  template: `
    <ion-header>
      <ion-toolbar>
        <ion-title> Blank </ion-title>
      </ion-toolbar>
    </ion-header>

    <ion-content [fullscreen]="true">
      <ion-button (click)="openModal()">open modal</ion-button>
    </ion-content>
  `,
})
export class HomePage {
  constructor(private modalController: ModalController) {}

  async openModal() {
    const modal = await this.modalController.create({
      component: ImgViewerComponent,
    });

    modal.present();
  }
}

@Component({
  template: `
    <ion-header>
      <ion-toolbar>
        <ion-title>Try to close it</ion-title>
        <ion-buttons slot="primary">
          <ion-button (click)="close()">
            <ion-icon slot="icon-only" name="close"></ion-icon>
          </ion-button>
        </ion-buttons>
      </ion-toolbar>
    </ion-header>

    <ion-content [fullscreen]="true" class="content">
      <ion-slides [options]="sliderOpts">
        <ion-slide>
          <div class="swiper-zoom-container">
            <img [src]="imageUrl" />
          </div>
        </ion-slide>
      </ion-slides>
    </ion-content>
  `,
  styles: [
    `
      ion-slides {
        height: 100%;
      }
    `,
  ],
})
export class ImgViewerComponent {
  imageUrl =
    'https://blog.soat.fr/wp-content/uploads/2017/11/ionic-logo-landscape-600x199.png';

  sliderOpts = {
    zoom: {
      maxRatio: 5,
    },
  };

  constructor(private modalController: ModalController) {}

  close() {
    this.modalController.dismiss();
  }
}

Import ImgViewerComponent in home.module.ts in the declarations array:

  declarations: [HomePage, ImgViewerComponent]

Code Reproduction URL

https://github.com/JumBay/ionic5-modal-issue

Ionic Info

Ionic:

   Ionic CLI                     : 6.16.3 (/Users/jb/.asdf/installs/nodejs/14.17.3/.npm/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.6.13
   @angular-devkit/build-angular : 12.2.0
   @angular-devkit/schematics    : 12.1.4
   @angular/cli                  : 12.2.0
   @ionic/angular-toolkit        : 4.0.0

Capacitor:

   Capacitor CLI      : 3.1.2
   @capacitor/android : 3.1.2
   @capacitor/core    : 3.1.2
   @capacitor/ios     : not installed

Utility:

   cordova-res : not installed globally
   native-run  : 1.4.0

System:

   NodeJS : v14.17.3 (/Users/jb/.asdf/installs/nodejs/14.17.3/bin/node)
   npm    : 6.14.13
   OS     : macOS Big Sur

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
liamdebeasicommented, Aug 26, 2021

Thanks for the issue! This has been resolved in Angular DevKit. Please update to the latest version to receive this fix:

npm install @angular-devkit/build-angular@latest
2reactions
liamdebeasicommented, Aug 10, 2021

Thanks! Looks like there was a bug in @angular-devkit/build-angular@12.2.0 that caused this issue. We are looking into reporting this to the Angular team.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modal controller does not trigger ngOnDestroy when dismissing
Present a modal component with modalController. In the component, implement the OnDestroy interface and write to the console to see the bug. In ......
Read more >
Ionic Modal On Dismiss Bug - Stack Overflow
Try to change your code this way async showLoginModal() { const modal = await this.modalController.create({ component: LoginModalComponent }); ...
Read more >
ion-modal: Ionic Mobile App Custom Modal API Component
ion-modal is a dialog that appears on top of mobile app content, and must be dismissed before interaction resumes. Learn more about custom...
Read more >
Merge translations into the application - Angular
To merge the completed translations into your project, complete the following actions. Use the Angular CLI to build a copy of the distributable...
Read more >
Identify and Fix Build and Deployment Errors in Your Angular ...
One of the most common Angular errors is the infamous "Module not found" error. This error is seen a lot because it can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found