Skip to content

Commit

Permalink
Prevent HoverCardContent click events from bubbling up (#395)
Browse files Browse the repository at this point in the history
* prevent click events from bubbling up

* versioning
  • Loading branch information
melanieseltzer authored Jan 22, 2025
1 parent cfab68a commit 3d60115
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/mantle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "mantle is ngrok's UI library and design system.",
"author": "ngrok",
"license": "MIT",
"version": "0.19.1",
"version": "0.19.2",
"homepage": "https://mantle.ngrok.com",
"repository": {
"type": "git",
Expand Down
9 changes: 8 additions & 1 deletion packages/mantle/src/components/hover-card/hover-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const HoverCardPortal = HoverCardPrimitive.Portal;
const HoverCardContent = forwardRef<
ElementRef<typeof HoverCardPrimitive.Content>,
ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
>(({ className, onClick, align = "center", sideOffset = 4, ...props }, ref) => (
<HoverCardPortal>
<HoverCardPrimitive.Content
ref={ref}
Expand All @@ -38,6 +38,13 @@ const HoverCardContent = forwardRef<
"data-state-open:animate-in data-state-closed:animate-out data-state-closed:fade-out-0 data-state-open:fade-in-0 data-state-closed:zoom-out-95 data-state-open:zoom-in-95 data-side-bottom:slide-in-from-top-2 data-side-left:slide-in-from-right-2 data-side-right:slide-in-from-left-2 data-side-top:slide-in-from-bottom-2",
className,
)}
onClick={(event) => {
/**
* Prevent the click event from propagating up to parent/containing elements
*/
event.stopPropagation();
onClick?.(event);
}}
{...props}
/>
</HoverCardPortal>
Expand Down

1 comment on commit 3d60115

@vercel
Copy link

@vercel vercel bot commented on 3d60115 Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.