Skip to content

Commit

Permalink
fix(GoalCriteria): fix navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
LamaEats committed Mar 28, 2024
1 parent f014fe7 commit 7986282
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/components/GoalCriteria/GoalCriteria.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import { useGoalResource } from '../../hooks/useGoalResource';
import { ActivityFeedItem } from '../ActivityFeed';
import { IssueMeta } from '../IssueMeta';
import { Circle } from '../Circle';
import { routes } from '../../hooks/router';
import { NextLink } from '../NextLink';

import classes from './GoalCriteria.module.css';
import { tr } from './GoalCriteria.i18n';
Expand Down Expand Up @@ -128,9 +130,14 @@ const SimpleCriteria: React.FC<Omit<CriteriaProps, 'id'> & OnCheckCriteriaCallba
const GoalCriteria = forwardRef<HTMLSpanElement, Omit<GoalCriteriaProps, 'id'>>(({ title, goal, weight }, ref) => {
const { setPreview } = useGoalPreview();

const handleGoalCriteriaClick = useCallback(() => {
setPreview(goal.shortId, { title, id: goal.goalId });
}, [setPreview, title, goal]);
const handleGoalCriteriaClick = useCallback<React.MouseEventHandler<HTMLSpanElement>>(
(event) => {
if (event.metaKey || event.ctrlKey || !goal?.shortId) return;
event.preventDefault();
setPreview(goal.shortId, { title, id: goal.goalId });
},
[setPreview, title, goal],
);

return (
<>
Expand All @@ -146,8 +153,11 @@ const GoalCriteria = forwardRef<HTMLSpanElement, Omit<GoalCriteriaProps, 'id'>>(
/>
}
className={classes.GoalCriteriaGoalBadge}
onClick={handleGoalCriteriaClick}
text={title}
text={
<NextLink href={routes.goal(goal.shortId)} onClick={handleGoalCriteriaClick}>
{title}
</NextLink>
}
/>
</TableCell>
<TableCell width="3ch" className={classes.GoalCriteriaWeightColumn}>
Expand Down

0 comments on commit 7986282

Please sign in to comment.