Closed damirarh closed 2 years ago
Thanks for the issue. I can reproduce this behavior. The problem here is that getOverlay
, the function that getTop
calls does not take into consideration whether or not an overlay is presented: https://github.com/ionic-team/ionic-framework/blob/main/core/src/utils/overlays.ts#L233-L236. This issue impacts all overlays.
This may have been intentional, but I think getTop
implies getting the top overlay that is visible on the screen.
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.
Bug Report
Ionic version:
[x] 4.7.4
Current behavior: The call to
LoadingController.getTop()
returns the most recently created loading overlay even if it hasn't been presented/opened yet.Expected behavior: According to the docs,, the call to
LoadingController.getTop()
should only return a loading overlay if it has already been presented/opened.Steps to reproduce:
LoadingController.getTop()
returns the second overlay instead of the first one.LoadingController.dismiss()
doesn't dismiss the open loading overlay and returns false.Related code:
https://github.com/damirarh/ioni4-loading-ctrl
Other information: This behavior also makes it impossible to reliably close all opened loading overlays without having a reference to each opened instance (i.e. reimplement the behavior of
dismissAll
in Ionic 3) because there's no way to get to the previously opened loading overlay using theLoadingController
if an opened loading overlay was created afterward. I blogged about my attempt at implementingdismissAll
in Ionic 4.Ionic info: