Skip to content

fix(react): keep an IonPage in a modal from taking over the route - #31865

Merged
ShaneK merged 4 commits into
mainfrom
FW-6444
Dec 3, 2026
Merged

ShaneK merged 4 commits into
mainfrom
FW-6444

Conversation

@ShaneK

@ShaneK ShaneK commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Issue number: resolves internal


What is the current behavior?

Currently, an IonPage inside an inline IonModal (or any other inline overlay) registers with the IonRouterOutlet around it. The overlay is moved under ion-app when it's presented, so the outlet's check for nested pages misses it and the modal's page replaces the route's page element. After the modal is dismissed the outlet is still holding the modal's contents, which keeps them in memory as detached nodes, and navigating away no longer hides the real page.

What is the new behavior?

  • Inline overlays now give their children the same "not in an outlet" StackContext that hook overlays already get, so an IonPage inside them doesn't register with the outer outlet. An IonRouterOutlet inside the overlay still provides its own context, so routing inside a modal isn't affected.
  • An IonRouterOutlet with the ionPage prop no longer adds ion-page-invisible when it isn't inside an outlet. It relied on the parent outlet's transition to remove that class, and inside an inline overlay there's no parent outlet to register with anymore, so the modal's contents stayed at opacity 0.
  • Added a Playwright test that opens and closes a modal containing an IonPage, navigates away, and checks that the page gets hidden.
  • Added a Playwright test that navigates between two pages of an IonRouterOutlet inside a modal, once with a plain outlet and once with an ionPage outlet.

Does this introduce a breaking change?

  • Yes
  • No

Other information

On the React test app's modal page, closing the modal left 36 detached nodes before this change and none after, including across repeated open/close cycles. There's no automated test for the node count because heap snapshots in Playwright would be flaky, so the first new test checks the page-hiding symptom instead, which has the same cause.

On 9.0.15, opening one of these modals on a page that was loaded directly also re-fires that page's useIonViewWillEnter and useIonViewDidEnter, since the outlet runs a page transition for the modal's page. That came from the bug, so it doesn't happen anymore. onWillPresent and onDidPresent are the supported way to react to a modal opening.

@ShaneK
ShaneK requested a review from a team as a code owner December 2, 2026 21:52
@ShaneK
ShaneK requested a review from brandyscarney December 2, 2026 21:52
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Dec 3, 2026 7:42pm UTC

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

I also confirmed that 9.0.15 re-fires the page's useIonViewWillEnter and useIonViewDidEnter when the modal opens and the dev build doesn't, so the "I believe" in the description can become a statement.

Non-blocking: nothing covers an IonRouterOutlet inside an inline modal, which is the path the description says isn't affected. A test or a manual check before merging would close that gap.

@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, minor suggestion

@ShaneK
ShaneK added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit e4078c2 Dec 3, 2026
55 checks passed
@ShaneK
ShaneK deleted the FW-6444 branch December 3, 2026 20:24

This branch was successfully deployed

1 active deployment
Preview — 73de6783 Deployed Dec 3, 2026 by vercel[bot]
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