Skip to content

fix(react): remove relocated inline overlays orphaned on unmount#31223

Merged
ShaneK merged 2 commits into
mainfrom
fix/oprhaned-modals
Jun 17, 2026
Merged

fix(react): remove relocated inline overlays orphaned on unmount#31223
ShaneK merged 2 commits into
mainfrom
fix/oprhaned-modals

Conversation

@ShaneK

@ShaneK ShaneK commented Jun 16, 2026

Copy link
Copy Markdown
Member

Issue number: internal


What is the current behavior?

Currently, when an inline overlay (ion-modal, ion-popover) is rendered through React and CoreDelegate teleports its host out of the React-rendered location, unmounting the component can leave the host orphaned in the DOM. componentWillUnmount only recovered a relocated host when this.state.isOpen was true, so a host that was moved while still closed was never reattached for React to remove. That happens during the React 18 StrictMode mount/unmount cycle, or any re-render before the present events flip isOpen. The result is duplicate <ion-modal> elements stacking up in document.body. This came from the portal change in #31159

What is the new behavior?

This splits the unmount cleanup into two independent steps. The DOM recovery now runs whenever the host is still connected and has been relocated, regardless of open state: portaled overlays get reattached to portalTarget so React's removeChild can find them, and nested overlays moved out of their <template> are removed directly. The dismiss-lifecycle teardown, detaching the didDismiss listener and props, stays gated on isOpen as before. So a relocated-but-closed host is now cleaned up instead of orphaned.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@ShaneK ShaneK requested a review from a team as a code owner June 16, 2026 19:37
@ShaneK ShaneK requested a review from brandyscarney June 16, 2026 19:37
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment Jun 16, 2026 7:42pm

Request Review

@thetaPC thetaPC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ShaneK ShaneK added this pull request to the merge queue Jun 17, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 17, 2026
@ShaneK ShaneK added this pull request to the merge queue Jun 17, 2026
Merged via the queue into main with commit d28d25b Jun 17, 2026
63 checks passed
@ShaneK ShaneK deleted the fix/oprhaned-modals branch June 17, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: react @ionic/react package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants