From e86d30c00bdb20273dec83cd75460d629eb82072 Mon Sep 17 00:00:00 2001 From: lightbulbman Date: Fri, 4 Sep 2026 23:29:20 +0100 Subject: [PATCH 1/4] fix: highlight the snippets tab on the default manage view --- src/js/components/common/Toolbar.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/js/components/common/Toolbar.tsx b/src/js/components/common/Toolbar.tsx index 9504a1e9b..af3ac39e0 100644 --- a/src/js/components/common/Toolbar.tsx +++ b/src/js/components/common/Toolbar.tsx @@ -2,7 +2,7 @@ import { __, _x } from '@wordpress/i18n' import classnames from 'classnames' import React, { useMemo, useState } from 'react' import { isLicensed, shouldShowUpsell } from '../../utils/screen' -import { buildUrl } from '../../utils/urls' +import { buildUrl, fetchConstQueryParam } from '../../utils/urls' import { hasSeenDemo } from './demo/useDemoSeen' import { AiAgentIcon } from './icons/AiAgentIcon' import { BlueprintIcon } from './icons/BlueprintIcon' @@ -18,6 +18,17 @@ export const SUBPAGES = ['snippets', 'blueprints', 'cloud-community', 'cloud-lib const searchParams = new URLSearchParams(window.location.search) +const managePageSlug = window.CODE_SNIPPETS?.urls.manage + ? new URL(window.CODE_SNIPPETS.urls.manage).searchParams.get('page') + : null + +// The manage screen resolves an absent or unrecognised `subpage` to the first subpage, so +// mirror that fallback here — comparing against the raw param would leave every lower-nav +// tab inactive on the default Snippets view, which is where the page opens. +const activeSubpage = searchParams.get('page') === managePageSlug + ? fetchConstQueryParam('subpage', SUBPAGES) ?? SUBPAGES[0] + : null + interface UpperNavItemProps { name: string url: string @@ -157,7 +168,7 @@ const SubpageItem: React.FC = ({ subpage, label, Icon, isPro,