Skip to content

Commit

Permalink
Help Center: don't autoopen the Help Center in Support Sessions (#99164)
Browse files Browse the repository at this point in the history
  • Loading branch information
alshakero authored Jan 31, 2025
1 parent 1bbd6f9 commit 4f6f262
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/data-stores/src/help-center/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,23 @@ const E2E_USER_AGENT = 'wp-e2e-tests';
export const isE2ETest = () =>
typeof window !== 'undefined' && window.navigator.userAgent.includes( E2E_USER_AGENT );

export const isSupportSession = () => {
if ( typeof window !== 'undefined' ) {
return (
'isSupportSession' in window ||
// A bit hacky but much easier than passing down data from PHP in Jetpack
// Simple
!! document.querySelector( '#wp-admin-bar-support-session-details' ) ||
// Atomic
document.body.classList.contains( 'support-session' )
);
}
return false;
};

export function register(): typeof STORE_KEY {
const enabledPesistedOpenState = ! isE2ETest() && ! isSupportSession();

registerPlugins();

if ( ! isRegistered ) {
Expand All @@ -28,7 +44,7 @@ export function register(): typeof STORE_KEY {
selectors,
persist: [ 'message', 'userDeclaredSite', 'userDeclaredSiteUrl', 'subject' ],
// Don't persist the open state for e2e users, because parallel tests will start interfering with each other.
resolvers: isE2ETest() ? undefined : { isHelpCenterShown },
resolvers: enabledPesistedOpenState ? { isHelpCenterShown } : undefined,
} );
isRegistered = true;
}
Expand Down

0 comments on commit 4f6f262

Please sign in to comment.