Skip to content

Commit

Permalink
fix: allow opening duplicate Modal route stacks. (#6235)
Browse files Browse the repository at this point in the history
  • Loading branch information
huhuanming authored Nov 27, 2024
1 parent 2d6e686 commit 54ff092
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/kit/src/hooks/useAppNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ function useAppNavigation<
rootNavigation = rootNavigation.getParent();
}

const routeLength = rootNavigation?.getState?.()?.routes?.length ?? 1;
const existPageIndex = rootNavigation?.getState?.()?.routes?.findIndex(
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(rootRoute) => params?.screen === rootRoute?.params?.params?.screen,
);
if ((existPageIndex ?? -1) !== -1) {
if (existPageIndex !== -1 && existPageIndex === routeLength - 1) {
return;
}

Expand Down Expand Up @@ -150,7 +151,7 @@ function useAppNavigation<
params?: IModalParamList[T][keyof IModalParamList[T]];
},
) => {
pushModalPage(ERootRoutes.Modal, route, params);
pushModalPage(ERootRoutes.Modal, route, params as any);
},
[pushModalPage],
);
Expand All @@ -163,7 +164,7 @@ function useAppNavigation<
params?: IModalParamList[T][keyof IModalParamList[T]];
},
) => {
pushModalPage(ERootRoutes.iOSFullScreen, route, params);
pushModalPage(ERootRoutes.iOSFullScreen, route, params as any);
},
[pushModalPage],
);
Expand Down

0 comments on commit 54ff092

Please sign in to comment.