From 9d45f6b5e71eb770cbf4f9319872c2f3fe00b798 Mon Sep 17 00:00:00 2001 From: Charles Garrett Date: Tue, 21 May 2024 10:54:06 -0400 Subject: [PATCH] chore: a more stable implemention of the dynamic More->Develop->Inspect menu option --- src/components/sidebar-navigation/MarketingDrawer.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/sidebar-navigation/MarketingDrawer.tsx b/src/components/sidebar-navigation/MarketingDrawer.tsx index e5aa75f16..89712ebb9 100644 --- a/src/components/sidebar-navigation/MarketingDrawer.tsx +++ b/src/components/sidebar-navigation/MarketingDrawer.tsx @@ -29,18 +29,20 @@ export const MarketingDrawer = ({ expanded }: Props) => { useEffect(() => { const developLinks = marketingDrawerSections[1].links; + const title = 'Inspect Component'; + const isInspectVisible = developLinks.some((option) => option.title === title); const isComponentURL = () => ['/widget/', '/component/'].some((p) => router.asPath.indexOf(p) !== -1); - if (currentComponentSrc && developLinks.length === 5) { + if (currentComponentSrc && !isInspectVisible) { developLinks.unshift({ - title: 'Inspect Component', + title, url: `/near/widget/ComponentDetailsPage?src=${currentComponentSrc}`, icon: 'ph-magnifying-glass ph-bold', }); - } else if (!isComponentURL() && !currentComponentSrc && developLinks.length === 6) { + } else if (!isComponentURL() && !currentComponentSrc && isInspectVisible) { developLinks.shift(); } - }, [currentComponentSrc, router]); + }, [currentComponentSrc, router.asPath]); return (