Skip to content

Commit

Permalink
Merge pull request #1183 from near/fix_inspect
Browse files Browse the repository at this point in the history
a more stable implemention of the dynamic More->Develop->Inspect menu option
  • Loading branch information
charleslavon authored May 21, 2024
2 parents 78cc218 + 9d45f6b commit 68cd8ca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/sidebar-navigation/MarketingDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<S.Drawer $expanded={expanded} $openedOnSmallScreens={isOpenedOnSmallScreens} onClick={handleBubbledClickInDrawer}>
Expand Down

0 comments on commit 68cd8ca

Please sign in to comment.