Skip to content

Commit

Permalink
fix(router): don't use replace on every route when going back (#2464)
Browse files Browse the repository at this point in the history
Co-authored-by: Fernando Fernández <[email protected]>
  • Loading branch information
ToastKiste21 and ferferga authored Sep 18, 2024
1 parent 43c3d5d commit ccb0754
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions frontend/src/plugins/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ router.beforeEach(metaGuard);
*/
const backTransition = 'slide-x';

router.back = (): ReturnType<typeof router.back> => {
router.back = () => {
const route = router.currentRoute;

/**
Expand All @@ -54,11 +54,13 @@ router.back = (): ReturnType<typeof router.back> => {
leave: route.value.meta.layout.transition.leave ?? backTransition
};

void router.replace(
isStr(router.options.history.state.back)
? router.options.history.state.back
: '/'
);
const historyState = router.options.history.state;

if (historyState && isStr(historyState.back)) {
router.go(-1);
} else {
router.replace('/');
}
};

/**
Expand Down

0 comments on commit ccb0754

Please sign in to comment.