Skip to content
Merged
Show file tree
Hide file tree
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
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Onboarding: keep the welcome modal open on a click outside it, so the tour can still be started.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,15 @@ describe( 'OnboardingWelcomeModal', () => {
expect( onDismiss ).toHaveBeenCalledTimes( 1 );
expect( onDismiss ).toHaveBeenCalledWith( 'escape' );
} );

it( 'stays open on a click outside, without counting a dismissal', async () => {
const { onDismiss } = renderModal();

await userEvent.click( document.body );

expect(
screen.getByRole( 'dialog', { name: 'Welcome to the new Traffic page' } )
).toBeInTheDocument();
expect( onDismiss ).not.toHaveBeenCalled();
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { useCallback } from 'react';
import { WidgetGridAnimation } from '../widget-grid-animation';
import styles from './onboarding-welcome-modal.module.scss';

/** How the reader closed the modal without starting: the close button, Escape or a click outside. */
export type OnboardingDismissReason = 'close' | 'escape' | 'outside' | 'other';
/** How the reader closed the modal without starting: the close button or Escape. */
export type OnboardingDismissReason = 'close' | 'escape' | 'other';

// Base UI names the cause on `onOpenChange`; these are the three a reader can produce.
// Base UI names the cause on `onOpenChange`; these are the two a reader can produce.
const DISMISS_REASONS: Record< string, OnboardingDismissReason > = {
'close-press': 'close',
'escape-key': 'escape',
'outside-press': 'outside',
};

type OpenChangeDetails = {
Expand Down Expand Up @@ -49,8 +48,10 @@ export function OnboardingWelcomeModal( {
[ onDismiss ]
);

// A click on the backdrop must not end the journey: the modal opens once per
// reader, so a stray click would lose the tour for good.
return (
<Dialog.Root open={ open } onOpenChange={ handleOpenChange }>
<Dialog.Root open={ open } onOpenChange={ handleOpenChange } disablePointerDismissal>
<Dialog.Popup size="small">
<Dialog.CloseIcon className={ styles.close } />
{ /* The stage lives in the scroll region so the copy and the button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const meta: Meta< typeof OnboardingWelcomeModal > = {
'the tour.\n\n' +
'The consumer owns the open state. `onStart` fires when the reader ' +
'presses Take a quick tour; `onDismiss` when they close the dialog any other ' +
'way, naming which (the close button, Escape, a click outside). The ' +
'way, naming which (the close button or Escape; a click outside is ignored). The ' +
'onboarding hook decides what each one means for the journey.\n\n' +
'On viewports too short for the animation, the copy and the tour button ' +
'take the room instead; on the ones in between, the content scrolls ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { store as preferencesStore } from '@wordpress/preferences';
*/
import { DASHBOARD_ONBOARDING_KEY, DASHBOARD_PREFERENCES_SCOPE } from './constants';
import { useTrackEvent } from './use-track-event';
import type { OnboardingDismissReason } from '@jetpack-premium-analytics/ui';

export type OnboardingPhase = 'closed' | 'modal' | 'tour';

/** How the reader closed the journey without finishing it. */
export type OnboardingDismissReason = 'close' | 'escape' | 'outside' | 'other';
export type { OnboardingDismissReason };

export type OnboardingOptions = {
/** Whether the reader is on the surface the journey introduces; nothing opens until then. */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Premium Analytics: keep the onboarding welcome modal open on a click outside it, so the tour can still be started.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Onboarding: keep the welcome modal open on a click outside it, so the tour can still be started.
Loading