fix(router): don't use replace on every route when going back (#2464)
Some checks failed
Push & Release 🌍 / Automation 🎛️ (push) Failing after 35s
Push & Release 🌍 / ${{ github.event_name == 'push' && 'Unstable 🚀⚠️' || 'Stable 🏷️✅' }} (push) Failing after 33s
Push & Release 🌍 / Deploy 🚀 (push) Has been skipped
Push & Release 🌍 / GitHub CodeQL 🔬 (push) Failing after 33s

Co-authored-by: Fernando Fernández <ferferga@hotmail.com>
This commit is contained in:
ToastKiste21 2024-09-18 14:45:15 +02:00 committed by GitHub
parent 43c3d5d1b9
commit ccb0754ae0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,7 +42,7 @@ router.beforeEach(metaGuard);
*/
const backTransition = 'slide-x';
router.back = (): ReturnType<typeof router.back> => {
router.back = () => {
const route = router.currentRoute;
/**
@ -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('/');
}
};
/**