Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show 'Back to page' notification when navigating away from page #51880

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
} ),
[]
);

Expand All @@ -39,6 +42,7 @@ export function useBackToPageNotification() {
useEffect( () => {
if (
! alreadySeen.current &&
isPage &&
prevHasPageContentFocus.current &&
! hasPageContentFocus
) {
Expand All @@ -57,6 +61,7 @@ export function useBackToPageNotification() {
prevHasPageContentFocus.current = hasPageContentFocus;
}, [
alreadySeen,
isPage,
prevHasPageContentFocus,
hasPageContentFocus,
createInfoNotice,
Expand Down