Skip to content

Commit

Permalink
fix: goalPreview open when clicked in an empty area inside GoalListItem
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisVorop committed Feb 26, 2024
1 parent a46a1d9 commit 2d8b5a0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 31 deletions.
50 changes: 25 additions & 25 deletions src/components/GoalTableList/GoalTableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,7 @@ export const GoalTableList = <T extends Partial<NonNullable<GoalByIdReturnType>>
{
content: (
<>
<Link
as={NextLink}
href={routes.goal(goal?._shortId as string)}
inline
onClick={onGoalPreviewShow(goal)}
>
<Text>{goal.title}</Text>
</Link>
<Text>{goal.title}</Text>
{nullable(goal.tags, (tags) => (
<TagsList>
{tags.map((tag) => (
Expand Down Expand Up @@ -135,29 +128,36 @@ export const GoalTableList = <T extends Partial<NonNullable<GoalByIdReturnType>>
},
],
})),
[goals, locale, onGoalPreviewShow, onTagClick],
[goals, locale, onTagClick],
);

return (
<Table {...attrs}>
{data.map((row) => (
<ListViewItem
<Link
key={row.goal.id}
value={row.goal}
renderItem={({ active, hovered: _, ...props }) => (
<TableListItem
selected={selectedGoalResolver?.(row.goal?.id as string)}
hovered={active}
{...props}
>
{row.list.map(({ content, width, className }, index) => (
<TableListItemElement key={index} width={width} className={className}>
{content}
</TableListItemElement>
))}
</TableListItem>
)}
/>
as={NextLink}
href={routes.goal(row.goal?._shortId as string)}
onClick={onGoalPreviewShow(row.goal)}
inline
>
<ListViewItem
value={row.goal}
renderItem={({ active, hovered: _, ...props }) => (
<TableListItem
selected={selectedGoalResolver?.(row.goal?.id as string)}
hovered={active}
{...props}
>
{row.list.map(({ content, width, className }, index) => (
<TableListItemElement key={index} width={width} className={className}>
{content}
</TableListItemElement>
))}
</TableListItem>
)}
/>
</Link>
))}
</Table>
);
Expand Down
25 changes: 19 additions & 6 deletions src/components/NewGoalCriteria/NewGoalCriteria.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useRef, useState } from 'react';
import React, { MouseEvent, useCallback, useRef, useState } from 'react';
import { Checkbox, CircleProgressBar, Table, TableCell, TableRow, Text, Popup, Badge } from '@taskany/bricks/harmony';
import { Spinner, nullable, useClickOutside } from '@taskany/bricks';
import classNames from 'classnames';
Expand Down Expand Up @@ -151,11 +151,20 @@ export const GoalCriteriaPreview: React.FC<GoalCriteriaPreviewProps> = ({ achiev
}
});

const handleOpen = useCallback(() => {
if (!popupVisible) {
setPopupVisible(true);
}
}, [popupVisible]);
const handleOpen = useCallback(
(e: MouseEvent<HTMLSpanElement>) => {
// block following a link that hangs on the entire table row
e.preventDefault();

// block opening GoalPreview
e.stopPropagation();

if (!popupVisible) {
setPopupVisible(true);
}
},
[popupVisible],
);

return (
<>
Expand All @@ -169,6 +178,10 @@ export const GoalCriteriaPreview: React.FC<GoalCriteriaPreviewProps> = ({ achiev
offset={[10, 10]}
arrow={false}
onClickCapture={() => setPopupVisible(false)}
onClick={(e) => {
// block opening GoalPreview
e.stopPropagation();
}}
>
<div className={classes.NewGoalCriteria} ref={wrapperRef}>
<Text className={classes.NewGoalCriteriaTitle} as="h4">
Expand Down

0 comments on commit 2d8b5a0

Please sign in to comment.