Skip to content

Commit

Permalink
Merge pull request #9358 from google/enhancement/#8874-audience-scrol…
Browse files Browse the repository at this point in the history
…l-area

Scroll to audiences widget area
  • Loading branch information
techanvil authored Sep 17, 2024
2 parents 68114d6 + 20635a2 commit 40f5363
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ import { useDispatch, useSelect } from 'googlesitekit-data';
import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants';
import { Button } from 'googlesitekit-components';
import SubtleNotification from '../../SubtleNotification';
import useViewOnly from '../../../../../hooks/useViewOnly';
import { getContextScrollTop } from '../../../../../util/scroll';
import { useBreakpoint } from '../../../../../hooks/useBreakpoint';
import useDashboardType, {
DASHBOARD_TYPE_MAIN,
} from '../../../../../hooks/useDashboardType';
import useViewOnly from '../../../../../hooks/useViewOnly';

export const AUDIENCE_SEGMENTATION_SETUP_SUCCESS_NOTIFICATION =
'audience_segmentation_setup_success_notification';

export default function AudienceSegmentationSetupSuccessSubtleNotification() {
const breakpoint = useBreakpoint();
const dashboardType = useDashboardType();
const viewOnly = useViewOnly();

Expand All @@ -60,11 +63,21 @@ export default function AudienceSegmentationSetupSuccessSubtleNotification() {
dismissItem( AUDIENCE_SEGMENTATION_SETUP_SUCCESS_NOTIFICATION );
}

function scrollToWidgetArea() {
const scrollToWidgetArea = ( event ) => {
event.preventDefault();

dismissNotificationForUser();

// TODO: Scrolling to the widget area will be implemented in a subsequent issue.
}
setTimeout( () => {
const widgetClass =
'.googlesitekit-widget-area--mainDashboardTrafficAudienceSegmentation';

global.scrollTo( {
top: getContextScrollTop( widgetClass, breakpoint ),
behavior: 'smooth',
} );
}, 50 );
};

const shouldShowNotification =
// Only show this notification on the main dashboard, where the Setup CTA Banner is shown.
Expand Down

0 comments on commit 40f5363

Please sign in to comment.