Skip to content

Commit

Permalink
Merge pull request #9527 from hicommonwealth/kaleemNeslit.9260.clicka…
Browse files Browse the repository at this point in the history
…ble_breadcrumbs

made the Discussion clickable and navigate to discussionAll
  • Loading branch information
KaleemNeslit authored Oct 11, 2024
2 parents 2fa11c6 + a285377 commit 5a8f7ae
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLSpanElement>) => void,
event: React.MouseEvent<HTMLSpanElement>,
) => {
if (label !== 'Discussions') {
handleInteraction(event);
}
};

export const CWBreadcrumbs = ({
breadcrumbs,
tooltipStr,
Expand All @@ -36,14 +51,19 @@ export const CWBreadcrumbs = ({
placement="bottom"
renderTrigger={(handleInteraction) => (
<CWText
onMouseEnter={handleInteraction}
onMouseLeave={handleInteraction}
onMouseEnter={(event) =>
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)}
</CWText>
Expand Down

0 comments on commit 5a8f7ae

Please sign in to comment.