From 4001fe3717607ae0069222fc27493308325125ec Mon Sep 17 00:00:00 2001 From: ToastKiste21 Date: Tue, 17 Sep 2024 20:31:51 +0200 Subject: [PATCH 1/4] fix(router): replace custom back method with window.history.back() to fix history navigation --- frontend/src/plugins/router/index.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/frontend/src/plugins/router/index.ts b/frontend/src/plugins/router/index.ts index a337d85b863..f5e7d9b6897 100644 --- a/frontend/src/plugins/router/index.ts +++ b/frontend/src/plugins/router/index.ts @@ -42,23 +42,15 @@ router.beforeEach(metaGuard); */ const backTransition = 'slide-x'; -router.back = (): ReturnType => { +router.back = () => { const route = router.currentRoute; - /** - * Play the default page transition but reversed, to play a different effect when going - * to the previous page. - */ route.value.meta.layout.transition = { enter: 'slide-x-reverse', leave: route.value.meta.layout.transition.leave ?? backTransition }; - void router.replace( - isStr(router.options.history.state.back) - ? router.options.history.state.back - : '/' - ); + window.history.back(); }; /** From b5195d4e4ea02b105a55d97e9c47526e5388b580 Mon Sep 17 00:00:00 2001 From: ToastKiste21 Date: Wed, 18 Sep 2024 00:20:16 +0200 Subject: [PATCH 2/4] fix(router): ensure back navigation stays within app scope --- frontend/src/plugins/router/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/plugins/router/index.ts b/frontend/src/plugins/router/index.ts index f5e7d9b6897..8a8b333162f 100644 --- a/frontend/src/plugins/router/index.ts +++ b/frontend/src/plugins/router/index.ts @@ -50,7 +50,13 @@ router.back = () => { leave: route.value.meta.layout.transition.leave ?? backTransition }; - window.history.back(); + const historyState = router.options.history.state; + + if (historyState && isStr(historyState.back)) { + router.go(-1); + } else { + router.replace('/'); + } }; /** From aae5873e04a46ac864c1a8324cbb218808c521d1 Mon Sep 17 00:00:00 2001 From: ToastKiste21 Date: Wed, 18 Sep 2024 12:19:51 +0200 Subject: [PATCH 3/4] fix(router): re-introduction the deleted comment --- frontend/src/plugins/router/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/src/plugins/router/index.ts b/frontend/src/plugins/router/index.ts index 8a8b333162f..0693ddb4a56 100644 --- a/frontend/src/plugins/router/index.ts +++ b/frontend/src/plugins/router/index.ts @@ -45,6 +45,11 @@ const backTransition = 'slide-x'; router.back = () => { const route = router.currentRoute; + /** + * Play the default page transition but reversed, to play a different effect when going + * to the previous page. + */ + route.value.meta.layout.transition = { enter: 'slide-x-reverse', leave: route.value.meta.layout.transition.leave ?? backTransition From a547e03e9eb07c203ef26325b415d4df31739865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Fern=C3=A1ndez?= Date: Wed, 18 Sep 2024 14:36:58 +0200 Subject: [PATCH 4/4] chore: formatting --- frontend/src/plugins/router/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/plugins/router/index.ts b/frontend/src/plugins/router/index.ts index 0693ddb4a56..9669c45dad2 100644 --- a/frontend/src/plugins/router/index.ts +++ b/frontend/src/plugins/router/index.ts @@ -45,11 +45,10 @@ const backTransition = 'slide-x'; router.back = () => { const route = router.currentRoute; - /** + /** * Play the default page transition but reversed, to play a different effect when going * to the previous page. */ - route.value.meta.layout.transition = { enter: 'slide-x-reverse', leave: route.value.meta.layout.transition.leave ?? backTransition