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

feat: reusable modals #20263

Closed
NiklasMerz opened this issue Jan 22, 2020 · 7 comments
Closed

feat: reusable modals #20263

NiklasMerz opened this issue Jan 22, 2020 · 7 comments
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement
Milestone

Comments

@NiklasMerz
Copy link
Contributor

Bug Report

Ionic version:

[x] 4.x

Current behavior:
Modals that are dismissed cannot be opened again. You need to create a new modal object before presenting. Modals cannot be reused.

Expected behavior:
In Ionic 3 I could create a modal and open and close it as much as I want to. I think reusing modal objects should be possible

Steps to reproduce:
See my repro project here. Open the modal by clicking open, dismiss it, click open again.

You can see that the browser console prints the log message from the modals onInit lifecycle hook but does not show the modals template.

Related code:

https://github.com/NiklasMerz/ionic-modal-repro

A sample application via GitHub

Other information:

Ionic info:

Ionic:

   Ionic CLI                     : 5.4.15 (/Users/niklasmerz/.nvm/versions/node/v12.14.1/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.11.8
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.1.2

Utility:

   cordova-res : not installed
   native-run  : 0.3.0

System:

   NodeJS : v12.14.1 (/Users/niklasmerz/.nvm/versions/node/v12.14.1/bin/node)
   npm    : 6.13.4
   OS     : macOS Catalina
@ionitron-bot ionitron-bot bot added the triage label Jan 22, 2020
@NiklasMerz NiklasMerz changed the title bug: bug: Modals cannot be opened after dismissing Jan 22, 2020
@NikolaPeevski
Copy link

This is not really a bug but more like a feature request ?

@NiklasMerz
Copy link
Contributor Author

Could be. But it looks like a bug/regression, breaking change, because it worked like that in Ionic 3 and our application broke after migrating to Ionic 4.

@liamdebeasi
Copy link
Contributor

Thanks for the issue. Can you provide some more clarification around your use case? Even in Ionic 3 modal components were not intended to be reusable. See the v3 docs here: https://ionicframework.com/docs/v3/api/components/modal/ModalController/#modal-controller

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Jan 27, 2020
@ionitron-bot ionitron-bot bot removed the triage label Jan 27, 2020
@NiklasMerz
Copy link
Contributor Author

Thanks I could not find the information that the modal controller object cannot be reused. But anyway I restructured the app logic to create a new page every time.

We use a modal that opens every time the app resumes and the ondiddismiss should be called every time. So we resused the the modal and did not need to attache the callback again.

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Jan 27, 2020
@liamdebeasi liamdebeasi added package: core @ionic/core package type: feature request a new feature, enhancement, or improvement labels Feb 4, 2020
@ionitron-bot ionitron-bot bot removed triage labels Feb 4, 2020
@liamdebeasi liamdebeasi changed the title bug: Modals cannot be opened after dismissing feat: reusable modals Feb 4, 2020
@dalepo
Copy link

dalepo commented Aug 6, 2020

If you change modals back then all modals relying on ngOnInit / ngOnDestroy will break.

@liamdebeasi liamdebeasi added this to the 6.0.0 milestone May 21, 2021
liamdebeasi added a commit that referenced this issue Jun 1, 2021
@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #23341, and you will be able to reuse modal instances by writing them declaratively in Ionic Framework v6. We will have updated docs that show you how to do this.

@ionitron-bot
Copy link

ionitron-bot bot commented Jul 1, 2021

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 Jul 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests

4 participants