@@ -232,8 +232,7 @@ export class StackManager extends React.PureComponent<StackManagerProps> {
232232 this . outOfScopeUnmountTimeout = undefined ;
233233 }
234234
235- const allViewsInOutlet = this . context . getViewItemsForOutlet ? this . context . getViewItemsForOutlet ( this . id ) : [ ] ;
236-
235+ const allViewsInOutlet = this . context . getViewItemsForOutlet ( this . id ) ;
237236 allViewsInOutlet . forEach ( ( viewItem ) => {
238237 hideIonPageElement ( viewItem . ionPageElement ) ;
239238 this . context . unMountViewItem ( viewItem ) ;
@@ -501,8 +500,7 @@ export class StackManager extends React.PureComponent<StackManagerProps> {
501500 return ;
502501 }
503502
504- const allViewsInOutlet = this . context . getViewItemsForOutlet ? this . context . getViewItemsForOutlet ( this . id ) : [ ] ;
505-
503+ const allViewsInOutlet = this . context . getViewItemsForOutlet ( this . id ) ;
506504 const areSiblingRoutes = ( path1 : string , path2 : string ) : boolean => {
507505 const path1IsRelative = ! path1 . startsWith ( '/' ) ;
508506 const path2IsRelative = ! path2 . startsWith ( '/' ) ;
@@ -569,8 +567,15 @@ export class StackManager extends React.PureComponent<StackManagerProps> {
569567 }
570568 this . pendingPageTransition = false ;
571569
572- // Hide the leaving view immediately for Navigate redirects
573- hideIonPageElement ( leavingViewItem ?. ionPageElement ) ;
570+ // Hide ALL other visible views in this outlet for Navigate redirects.
571+ // Same rationale as the timeout path: intermediate redirects can shift
572+ // the leaving view reference, leaving the original page visible.
573+ const allViewsInOutlet = this . context . getViewItemsForOutlet ( this . id ) ;
574+ allViewsInOutlet . forEach ( ( viewItem ) => {
575+ if ( viewItem . id !== enteringViewItem . id && viewItem . ionPageElement ) {
576+ hideIonPageElement ( viewItem . ionPageElement ) ;
577+ }
578+ } ) ;
574579
575580 // Don't unmount if entering and leaving are the same view item
576581 if ( shouldUnmountLeavingViewItem && leavingViewItem && enteringViewItem !== leavingViewItem ) {
@@ -617,11 +622,16 @@ export class StackManager extends React.PureComponent<StackManagerProps> {
617622 /**
618623 * Timeout fired and entering view still has no ionPageElement.
619624 * This happens for container routes that render nested outlets without a direct IonPage.
620- * Hide the leaving view since there's no entering IonPage to wait for.
625+ * Hide ALL other visible views in this outlet, not just the computed leaving view.
626+ * This handles cases where intermediate redirects (e.g., Navigate in nested routes)
627+ * change the leaving view reference, leaving the original page still visible.
621628 */
622- if ( latestLeavingView ?. ionPageElement ) {
623- hideIonPageElement ( latestLeavingView . ionPageElement ) ;
624- }
629+ const allViewsInOutlet = this . context . getViewItemsForOutlet ( this . id ) ;
630+ allViewsInOutlet . forEach ( ( viewItem ) => {
631+ if ( viewItem . id !== latestEnteringView . id && viewItem . ionPageElement ) {
632+ hideIonPageElement ( viewItem . ionPageElement ) ;
633+ }
634+ } ) ;
625635 this . forceUpdate ( ) ;
626636 }
627637 } , ION_PAGE_WAIT_TIMEOUT_MS ) ;
@@ -688,7 +698,7 @@ export class StackManager extends React.PureComponent<StackManagerProps> {
688698 // the nested outlet's componentDidUpdate won't be called, so we must hide
689699 // the ion-page elements here to prevent them from remaining visible on top
690700 // of other content after navigation to a different route.
691- const allViewsInOutlet = this . context . getViewItemsForOutlet ? this . context . getViewItemsForOutlet ( this . id ) : [ ] ;
701+ const allViewsInOutlet = this . context . getViewItemsForOutlet ( this . id ) ;
692702 allViewsInOutlet . forEach ( ( viewItem ) => {
693703 hideIonPageElement ( viewItem . ionPageElement ) ;
694704 } ) ;
0 commit comments