From f208880994d521d082063e241f869ce0ce7df901 Mon Sep 17 00:00:00 2001 From: Jimmy Madon Date: Wed, 16 Oct 2024 20:52:37 +0200 Subject: [PATCH] Fix PAX confirm notification button does not dismiss the notification from the screen. --- .../PAXSetupSuccessSubtleNotification.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/js/modules/ads/components/notifications/PAXSetupSuccessSubtleNotification.js b/assets/js/modules/ads/components/notifications/PAXSetupSuccessSubtleNotification.js index 1c3c33ab580..24a691ef604 100644 --- a/assets/js/modules/ads/components/notifications/PAXSetupSuccessSubtleNotification.js +++ b/assets/js/modules/ads/components/notifications/PAXSetupSuccessSubtleNotification.js @@ -24,6 +24,8 @@ import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ +import { useDispatch } from 'googlesitekit-data'; +import { CORE_NOTIFICATIONS } from '../../../../googlesitekit/notifications/datastore/constants'; import { getNavigationalScrollTop } from '../../../../util/scroll'; import SubtleNotification from '../../../../googlesitekit/notifications/components/layout/SubtleNotification'; import useQueryArg from '../../../../hooks/useQueryArg'; @@ -37,9 +39,11 @@ export default function PAXSetupSuccessSubtleNotification( { } ) { const breakpoint = useBreakpoint(); + const { dismissNotification } = useDispatch( CORE_NOTIFICATIONS ); + const [ , setNotification ] = useQueryArg( 'notification' ); - const onDismiss = () => { + const dismissNotice = () => { setNotification( undefined ); }; @@ -54,7 +58,8 @@ export default function PAXSetupSuccessSubtleNotification( { behavior: 'smooth', } ); - setNotification( undefined ); + dismissNotice(); + dismissNotification( id ); }, 50 ); }; @@ -74,7 +79,7 @@ export default function PAXSetupSuccessSubtleNotification( { id={ id } primary={ false } dismissLabel={ __( 'Got it', 'google-site-kit' ) } - onDismiss={ onDismiss } + onDismiss={ dismissNotice } /> } additionalCTA={