Skip to content

bug: inline popover stays presented after the component that holds it is removed #31858

Backlog

Description

@tzdevelopteam

Prerequisites

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

  1. Render an inline ion-popover inside a component, and present it with its trigger.
  2. While it is open, remove that component from the template.
  3. 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.

Code Reproduction URL

https://github.com/tzdevelopteam/ionic-popover-removed-parent-repro

Ionic Info

@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.

Activity

  1. Ultranmus commented on Dec 3, 2026

    @Ultranmus

    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.

  2. Ultranmus commented on Dec 3, 2026

    @Ultranmus

    Opened #31868 for this.

  3. thetaPC commented on Dec 3, 2026

    @thetaPC
    Contributor

    Thanks for the report!

    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.

    Tracked as a bug in core.

  4. added
    package: core
    type: bug
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: coretype: bug

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions