From 3c29ea4a4ba4411fdafefd6cb0ecdd26f6182db0 Mon Sep 17 00:00:00 2001 From: jboland88 <18016357+jboland88@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:35:07 -0400 Subject: [PATCH 1/2] Have the go back button in My Jetpack always go back to the homepage --- .../packages/my-jetpack/_inc/hooks/use-go-back/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/packages/my-jetpack/_inc/hooks/use-go-back/index.ts b/projects/packages/my-jetpack/_inc/hooks/use-go-back/index.ts index dd74ec57cf1a7..76a9efc72bc57 100644 --- a/projects/packages/my-jetpack/_inc/hooks/use-go-back/index.ts +++ b/projects/packages/my-jetpack/_inc/hooks/use-go-back/index.ts @@ -5,7 +5,9 @@ import { useCallback } from 'react'; /** * Internal dependencies */ +import { MyJetpackRoutes } from '../../constants'; import useAnalytics from '../use-analytics'; +import useMyJetpackNavigate from '../use-my-jetpack-navigate'; /** * Custom React hook to handle back link click with analytics. @@ -15,6 +17,7 @@ import useAnalytics from '../use-analytics'; */ export function useGoBack( { slug }: { slug: string } ) { const { recordEvent } = useAnalytics(); + const navigateToMyJetpackOverviewPage = useMyJetpackNavigate( MyJetpackRoutes.Home ); const onClickGoBack = useCallback( ( event: MouseEvent ) => { @@ -25,10 +28,10 @@ export function useGoBack( { slug }: { slug: string } ) { if ( document.referrer.includes( window.location.host ) ) { // Prevent default here to minimize page change within the My Jetpack app. event.preventDefault(); - history.back(); + navigateToMyJetpackOverviewPage(); } }, - [ recordEvent, slug ] + [ recordEvent, slug, navigateToMyJetpackOverviewPage ] ); return { onClickGoBack }; From 46c43951ed756fc2c2f7d123e8368ae3dea0b0ac Mon Sep 17 00:00:00 2001 From: jboland88 <18016357+jboland88@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:36:28 -0400 Subject: [PATCH 2/2] changelog --- .../changelog/update-change-go-back-behavior-in-my-jetpack | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/packages/my-jetpack/changelog/update-change-go-back-behavior-in-my-jetpack diff --git a/projects/packages/my-jetpack/changelog/update-change-go-back-behavior-in-my-jetpack b/projects/packages/my-jetpack/changelog/update-change-go-back-behavior-in-my-jetpack new file mode 100644 index 0000000000000..aa18d30e2a6a3 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/update-change-go-back-behavior-in-my-jetpack @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +change "go back" in My Jetpack interstitials to always return to the My Jetpack page