From a285377a894be8c1467399fc9dddea952e4707ee Mon Sep 17 00:00:00 2001 From: KaleemNeslit Date: Fri, 11 Oct 2024 01:47:04 +0500 Subject: [PATCH] made the Discussion clickable and navigate to discussionAll --- .../component_kit/cw_breadcrumbs.tsx | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/commonwealth/client/scripts/views/components/component_kit/cw_breadcrumbs.tsx b/packages/commonwealth/client/scripts/views/components/component_kit/cw_breadcrumbs.tsx index 33fc586ad32..dcda32e35cc 100644 --- a/packages/commonwealth/client/scripts/views/components/component_kit/cw_breadcrumbs.tsx +++ b/packages/commonwealth/client/scripts/views/components/component_kit/cw_breadcrumbs.tsx @@ -20,6 +20,21 @@ type BreadcrumbsProps = { tooltipStr?: string; }; +const handleNavigation = (label, navigate, isParent) => { + if (label === 'Discussions' && isParent) { + navigate(`/discussions`); + } +}; +const handleMouseInteraction = ( + label: string, + handleInteraction: (event: React.MouseEvent) => void, + event: React.MouseEvent, +) => { + if (label !== 'Discussions') { + handleInteraction(event); + } +}; + export const CWBreadcrumbs = ({ breadcrumbs, tooltipStr, @@ -36,14 +51,19 @@ export const CWBreadcrumbs = ({ placement="bottom" renderTrigger={(handleInteraction) => ( + handleMouseInteraction(label, handleInteraction, event) + } + onMouseLeave={(event) => + handleMouseInteraction(label, handleInteraction, event) + } type="caption" className={clsx({ 'disable-active-cursor': index === 0, 'current-text': isCurrent, 'parent-text': !isCurrent, })} + onClick={() => handleNavigation(label, navigate, isParent)} > {truncateText(label)}