Skip to content

Commit e8eb0e1

Browse files
authored
Merge pull request #78 from nicolethoen/fix_href_onclick
fix: address regression when onclick and href provided
2 parents 7738f40 + bb176fe commit e8eb0e1

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

packages/module/src/components/CatalogTile/CatalogTile.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,24 @@ export class CatalogTile extends React.Component<CatalogTileProps> {
6363
private handleClick = (e: React.FormEvent<HTMLInputElement> | React.MouseEvent<Element, MouseEvent>) => {
6464
const { onClick, href } = this.props;
6565

66-
if (!href) {
67-
e.preventDefault();
68-
} else {
66+
if ("type" in e && e.type === "click" && onClick) {
67+
// It's a MouseEvent
68+
const mouseEvent = e as React.MouseEvent<Element, MouseEvent>;
69+
if (
70+
mouseEvent.metaKey || // Cmd key (Mac)
71+
mouseEvent.ctrlKey || // Ctrl key
72+
mouseEvent.shiftKey // Shift key
73+
) {
74+
window.open(href, '_blank');
75+
return;
76+
}
77+
} else if (href){
6978
window.open(href, '_blank');
7079
}
80+
7181
if (onClick) {
7282
onClick(e);
73-
}
83+
}
7484
};
7585

7686
private renderBadges = (badges: React.ReactNode[]) => {

0 commit comments

Comments
 (0)