Repository navigation
fix(react-router): hide preserved page when re-entering an ionPage outlet at a different page - #31806
Open
AdityaxDeore wants to merge 1 commit into
Open
AdityaxDeore wants to merge 1 commit into
AdityaxDeore wants to merge 1 commit into
Conversation
…tlet at a different page In iOS mode, handleOutOfScopeOutlet preserves an ionPage outlet's child views when the outlet goes out of scope so a swipe back can show them, but it does not hide the active child page. When the outlet comes back in scope at a different child route, the leaving view lookup misses (both lastPathname and prevRouteLastPathname belong to the parent outlet), so the transition shows the entering page and hides nothing, leaving the preserved page visible on top of the new one. Add hideOtherVisibleViews(), called from handleReadyEnteringView just before transitionPage: when the transition has no leaving page element to hide, every other visible view in the outlet is hidden (except the entering view and container routes when entering a container route). This mirrors the hide-all-others fallback already in handleWaitingForIonPage, which the ready path was missing. The leaving view is excluded because transitionPage hides it, and the call sits after the duplicate/skip-transition early returns, so swipe-back gestures are unaffected. Regression test: Playwright e2e swipe-preserved-page.spec.ts reproduces the issue steps (Step 1 -> Step 2 -> Home -> Settings -> Step 1, all forward pushes, iOS mode) and asserts Step 2 is hidden. Fail-before: Step 2 stayed visible (class 'ion-page can-go-back', no ion-page-hidden). Pass-after: 1 passed. Neighbouring specs (ionpage-swipe-back, hidden-view-renders, param-swipe-back): 9 passed. Fixes ionic-team#31708
|
@AdityaxDeore is attempting to deploy a commit to the Ionic Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #31708
Problem
In iOS mode, an
ionPagechild outlet can end up with two visible pages. The page that was active when the user left the outlet (Step 2) is never hidden, so when the user later returns to a different page in the same outlet (Step 1), the old page stays on screen and covers the new one. The URL is correct and no error is thrown. In md mode the same navigation works.Root cause
StackManager.handleOutOfScopeOutlethas a branch forionPageoutlets whose parent outlet hasswipeGesture === true(iOS mode default): when the outlet goes out of scope it keeps every child view mounted so a swipe back can show them, and returns without hiding the active child page. When the outlet comes back in scope at a different child route, the leaving view lookup misses (bothrouteInfo.lastPathnameandrouteInfo.prevRouteLastPathnamebelong to the parent outlet), so the transition shows the entering page and hides nothing. The extra Settings step matters: with only one outside navigation,prevRouteLastPathnamestill points at Step 2, so it is found as the leaving view and hidden.Fix
In
packages/react-router/src/ReactRouter/StackManager.tsx:hideOtherVisibleViews(enteringViewItem, leavingViewItem): hides every other visible, mounted view in the outlet — except the entering view, the leaving view (transitionPage hides it), and container routes when entering a container route (mirrorscleanupOrphanedSiblingViews). It runs only when the transition has no leaving page element to hide.handleReadyEnteringViewjust beforetransitionPage, after all duplicate/skip-transition early returns, so swipe-back gestures (which return early there and have a leaving element) are unaffected.This mirrors the hide-all-others fallback already in
handleWaitingForIonPage(the Navigate branch and theionPageWaitTimeoutpath), which the ready path was missing.Testing
New Playwright e2e spec
packages/react-router/test/base/tests/e2e/playwright/swipe-preserved-page.spec.tswith test pageswipe-preserved-page, reproducing the issue steps exactly (Step 1 → Step 2 → Home → Settings → Step 1, allrouter.push(path, 'forward'), iOS mode). It asserts the URL, Step 1 visible, and Step 2 carryingion-page-hidden.Fail-before on the unfixed build: Step 2 stayed visible (class
ion-page can-go-back, noion-page-hidden). Pass-after: 1 passed. Neighbouring specs on the fixed build —ionpage-swipe-back(2),hidden-view-renders(3),param-swipe-back(4): 9 passed.Typecheck, eslint and prettier are clean; the
@ionic/react-routerbuild passes.Related: the same helper also fixes #31709 path B (a redirect landing before the intermediate route's page registers leaves the pushed-from tab visible — the same no-leaving-element case). That issue additionally needs a
runCommitre-hide for its path A, which is a separate PR.Disclosure: AI coding assistance was used in preparing this change.