Skip to content

Commit

Permalink
fix: don't handle prune if there's only one route
Browse files Browse the repository at this point in the history
This was preventing the action from bubbling up which would prevent the screen from getting removed
  • Loading branch information
satya164 committed Mar 27, 2020
1 parent 66374db commit d2433f0
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions packages/core/src/routers/StackRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,18 +536,21 @@ export default (routeConfigs, stackConfig = {}) => {

if (action.type === StackActions.POP && prune === false && key) {
const index = state.routes.findIndex((r) => r.key === key);
const count = Math.max(index - (n == null ? 1 : n) + 1, 1);
const routes = state.routes
.slice(0, count)
.concat(state.routes.slice(index + 1));

if (routes.length) {
return {
...state,
routes,
index: routes.length - 1,
isTransitioning: immediate !== true,
};
if (index > 0) {
const count = Math.max(index - (n ?? 1) + 1, 1);
const routes = state.routes
.slice(0, count)
.concat(state.routes.slice(index + 1));

if (routes.length) {
return {
...state,
routes,
index: routes.length - 1,
isTransitioning: immediate !== true,
};
}
}
} else {
let backRouteIndex = state.index;
Expand Down

0 comments on commit d2433f0

Please sign in to comment.