You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: inline popover stays presented after the component that holds it is removed #31858
I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v9.x (reproduced on 9.0.14, also seen on 9.0.13)
Current Behavior
An inline ion-popover is moved into ion-app while it is presented. When the component that holds it is removed (an @if turns false, for example), the popover stays presented over the page: its backdrop keeps covering it and body keeps backdrop-no-scroll, until the user taps the backdrop. With Angular, the removed component's styles go with it, so the leftover popover may also lose its styling.
ion-modal had the same problem and was fixed in #30544 (it watches its original parent and dismisses itself when that is removed). ion-popover has no equivalent. In the reproduction the modal is dismissed and the popover is not.
(#23567 was about the leave animation on unmount; this is about the popover not going away at all.)
Expected Behavior
The popover is dismissed when the element it was presented from is removed, as ion-modal does.
Steps to Reproduce
Render an inline ion-popover inside a component, and present it with its trigger.
While it is open, remove that component from the template.
The popover is still in ion-app, presented, over the page.
In the reproduction: tap Open popover and wait three seconds. Reload and do the same with Open modal for comparison.
@ionic/angular 9.0.14, Angular 22.3.0 (zoneless, standalone), reproduced in desktop Chromium
Additional Information
core/src/components/modal/modal.tsx caches the original parent and, in initParentRemovalObserver(), dismisses the modal when it is removed; core/src/components/popover/popover.tsx only cleans up in disconnectedCallback, which does not run here because the popover itself is still connected. Giving the popover the same observer should fix it. We currently call dismiss() from the component's destroy hook, which works around it.
Thanks for the clear repro. I'd like to pick this up. I'll add the same parent removal check that ion-modal got in #30544 to ion-popover, plus an e2e test. I'll open a PR shortly.
Verified on 9.0.15. While it is open, an inline ion-popover is moved into ion-app, so removing the component that declared it does not remove the popover itself, and nothing tells it to close. ion-modal watches the element it was declared in and dismisses itself when that element is removed, but ion-popover has no such check yet. The backdrop stays up and body keeps backdrop-no-scroll until someone taps the backdrop.
Until that is fixed, calling dismiss() on the popover before its component is removed, as you are doing from the destroy hook, is the right workaround. It closes the popover and clears backdrop-no-scroll.
Activity
Ultranmus commentedon Dec 3, 2026
Thanks for the clear repro. I'd like to pick this up. I'll add the same parent removal check that ion-modal got in #30544 to ion-popover, plus an e2e test. I'll open a PR shortly.
Ultranmus commentedon Dec 3, 2026
Opened #31868 for this.
thetaPC commentedon Dec 3, 2026
Thanks for the report!
Verified on 9.0.15. While it is open, an inline
ion-popoveris moved intoion-app, so removing the component that declared it does not remove the popover itself, and nothing tells it to close.ion-modalwatches the element it was declared in and dismisses itself when that element is removed, bution-popoverhas no such check yet. The backdrop stays up andbodykeepsbackdrop-no-scrolluntil someone taps the backdrop.Until that is fixed, calling
dismiss()on the popover before its component is removed, as you are doing from the destroy hook, is the right workaround. It closes the popover and clearsbackdrop-no-scroll.Tracked as a bug in
core.