Skip to content

Commit 4e35673

Browse files
committed
avoid nested interactive elements in notification card
1 parent 7db160b commit 4e35673

1 file changed

Lines changed: 16 additions & 18 deletions

File tree

apps/webapp/app/components/navigation/NotificationCard.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,25 @@ export function NotificationCard({
4848
setIsExpanded((v) => !v);
4949
};
5050

51-
const Wrapper = actionUrl ? "a" : "div";
52-
const wrapperProps = actionUrl
53-
? {
54-
href: actionUrl,
55-
target: "_blank" as const,
56-
rel: "noopener noreferrer" as const,
57-
...(onCardClick ? { onClick: onCardClick } : {}),
58-
}
59-
: {};
60-
6151
return (
62-
<Wrapper
63-
{...wrapperProps}
64-
className="group/card block overflow-hidden rounded border border-charcoal-650 bg-charcoal-700/50 no-underline shadow-lg"
65-
>
52+
<div className="group/card relative overflow-hidden rounded border border-charcoal-650 bg-charcoal-700/50 shadow-lg">
53+
{actionUrl && (
54+
<a
55+
href={actionUrl}
56+
target="_blank"
57+
rel="noopener noreferrer"
58+
aria-label={title}
59+
onClick={onCardClick}
60+
className="absolute inset-0 z-10"
61+
/>
62+
)}
63+
6664
<div className="flex items-start gap-1 px-2.5 pt-2">
6765
<p className="flex-1 text-[13px] font-medium leading-normal text-text-bright">{title}</p>
6866
<button
6967
type="button"
7068
onClick={handleDismiss}
71-
className="-mr-1 shrink-0 rounded p-0.5 text-text-dimmed opacity-0 transition group-hover/card:opacity-100 hover:bg-charcoal-700 hover:text-text-bright"
69+
className="relative z-20 -mr-1 shrink-0 rounded p-0.5 text-text-dimmed opacity-0 transition group-hover/card:opacity-100 hover:bg-charcoal-700 hover:text-text-bright"
7270
>
7371
<XMarkIcon className="size-3.5" />
7472
</button>
@@ -84,15 +82,15 @@ export function NotificationCard({
8482
<button
8583
type="button"
8684
onClick={handleToggleExpand}
87-
className="mt-0.5 text-xs text-indigo-400 hover:text-indigo-300"
85+
className="relative z-20 mt-0.5 text-xs text-indigo-400 hover:text-indigo-300"
8886
>
8987
{isExpanded ? "Show less" : "Show more"}
9088
</button>
9189
)}
9290

9391
{image && <img src={sanitizeImageUrl(image)} alt="" className="mt-1.5 rounded" />}
9492
</div>
95-
</Wrapper>
93+
</div>
9694
);
9795
}
9896

@@ -106,7 +104,7 @@ function getMarkdownComponents(onLinkClick?: () => void) {
106104
href={href}
107105
target="_blank"
108106
rel="noopener noreferrer"
109-
className="text-indigo-400 underline transition-colors hover:text-indigo-300"
107+
className="relative z-20 text-indigo-400 underline transition-colors hover:text-indigo-300"
110108
onClick={(e) => {
111109
e.stopPropagation();
112110
onLinkClick?.();

0 commit comments

Comments
 (0)