From e4093ba26c9c33925068d18319c152b6d6964e35 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Mon, 26 Jun 2023 10:34:33 +1000 Subject: [PATCH] Don't show 'Back to page' notification when navigating away from page --- .../back-to-page-notification.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/page-content-focus-manager/back-to-page-notification.js b/packages/edit-site/src/components/page-content-focus-manager/back-to-page-notification.js index 171d4b6a5f757..a2990c56a673c 100644 --- a/packages/edit-site/src/components/page-content-focus-manager/back-to-page-notification.js +++ b/packages/edit-site/src/components/page-content-focus-manager/back-to-page-notification.js @@ -25,8 +25,11 @@ export default function BackToPageNotification() { * switches from focusing on editing page content to editing a template. */ export function useBackToPageNotification() { - const hasPageContentFocus = useSelect( - ( select ) => select( editSiteStore ).hasPageContentFocus(), + const { isPage, hasPageContentFocus } = useSelect( + ( select ) => ( { + isPage: select( editSiteStore ).isPage(), + hasPageContentFocus: select( editSiteStore ).hasPageContentFocus(), + } ), [] ); @@ -39,6 +42,7 @@ export function useBackToPageNotification() { useEffect( () => { if ( ! alreadySeen.current && + isPage && prevHasPageContentFocus.current && ! hasPageContentFocus ) { @@ -57,6 +61,7 @@ export function useBackToPageNotification() { prevHasPageContentFocus.current = hasPageContentFocus; }, [ alreadySeen, + isPage, prevHasPageContentFocus, hasPageContentFocus, createInfoNotice,