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 }; 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