Closed ndrakulic91 closed 2 years ago
I have the same problem, and I think that every Controller should have one "dissmissAll" function, and should exist one to close all Overlays at once like "dismissAllOverlays"
Thanks for the issue. Overlays can also be dismissed by calling dismiss()
on the element itself. Could you try the below snippet and let me know if it solves your use case?
import { HTMLIonOverlayElement } from '@ionic/core';
const closeAll = () => {
// adjust selector to fit your needs
const overlays = document.querySelectorAll('ion-alert, ion-action-sheet, ion-loading, ion-modal, ion-picker, ion-popover, ion-toast');
const overlaysArr = Array.from(overlays) as HTMLIonOverlayElement[];
overlaysArr.forEach(o => o.dismiss());
};
Thanks for the issue! This issue is being closed due to the lack of a reply. 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.
Thank you for using Ionic!
Prerequisites
Describe the Feature Request
Currently ModalController and AlertController are able to dismiss one modal at the time. In case of stacked modals/alerts, closing all active ones is not possible unless we keep track of those that are shown.
It would be very helpful if there would be a dismissAll() method which would close all active modals for ModalController or alerts for AlertController.
Describe the Use Case
A practical example is when user gets automatically logged out, all activr overlays should be closed. In case of stacked overlays it's impossible unless those are closed one by one using dismiss() method.
Describe Preferred Solution
No response
Describe Alternatives
No response
Related Code
No response
Additional Information
No response