Skip to content

Commit

Permalink
feat(card): #MAG-518 open preview with double-clic
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasSevagen committed Dec 2, 2024
1 parent bc139ee commit 392909d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions frontend/src/components/board-card/BoardCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const BoardCard: FC<BoardCardProps> = ({
handleFavoriteClick,
registerDropdown,
closeDropdown,
handleDoubleClick,
} = useBoardCard(card);

const { t } = useTranslation("magneto");
Expand Down Expand Up @@ -126,6 +127,7 @@ const BoardCard: FC<BoardCardProps> = ({
zoomLevel={zoomLevel}
isDragging={isDragging}
ref={setNodeRef}
onDoubleClick={handleDoubleClick}
style={style}
{...(readOnly ? {} : { ...attributes, ...listeners })}
>
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/hooks/useBoardCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const useBoardCard = (card: Card) => {
hasManageRights,
activeCard,
closeActiveCardAction,
openActiveCardAction,
} = useBoard();
const { user } = useUser();
const { openDropdownId, registerDropdown, toggleDropdown, closeDropdown } =
Expand Down Expand Up @@ -87,6 +88,14 @@ export const useBoardCard = (card: Card) => {
}
}, [card.id, toggleDropdown]);

const handleDoubleClick = useCallback(
(e: React.MouseEvent) => {
e.stopPropagation();
openActiveCardAction(card, BOARD_MODAL_TYPE.CARD_PREVIEW);
},
[card],
);

const handleDropdownClose = useCallback(() => {
toggleDropdown(null);
}, [toggleDropdown]);
Expand All @@ -109,6 +118,7 @@ export const useBoardCard = (card: Card) => {
handleFavoriteClick,
registerDropdown,
closeDropdown,
handleDoubleClick,
}),
[
icon,
Expand All @@ -122,6 +132,7 @@ export const useBoardCard = (card: Card) => {
handleFavoriteClick,
registerDropdown,
closeDropdown,
handleDoubleClick,
],
);
};

0 comments on commit 392909d

Please sign in to comment.