Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/components/CardHorizontal/CardHorizontal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,18 @@ describe("CardHorizontal Component", () => {
expect(windowOpenSpy).not.toHaveBeenCalled();
windowOpenSpy.mockRestore();
});

it("should not call onClick when isSelectable is false", () => {
const onClickMock = vitest.fn();
const { container } = renderCard({
title: "Test Card",
isSelectable: false,
onButtonClick: onClickMock,
});

const wrapper = container.firstChild as HTMLElement;
wrapper.click();

expect(onClickMock).not.toHaveBeenCalled();
});
});
2 changes: 1 addition & 1 deletion src/components/CardHorizontal/CardHorizontal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const CardHorizontal = ({
...props
}: CardHorizontalProps) => {
const handleClick = (e: React.MouseEvent<HTMLElement>) => {
if (disabled) {
if (disabled || !isSelectable) {
e.preventDefault();
return;
}
Expand Down