Skip to content

Commit 11227e4

Browse files
committed
remove anchors
1 parent a636625 commit 11227e4

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/components/docImageClient.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,16 @@ export function DocImageClient({
3030

3131
// For external images or invalid dimensions, fall back to regular img tag
3232
if (src.startsWith('http') || !isValidDimensions) {
33+
const handleClick = (e: React.MouseEvent) => {
34+
// If Ctrl/Cmd+click, open image in new tab
35+
if (e.ctrlKey || e.metaKey) {
36+
window.open(imgPath, '_blank', 'noreferrer');
37+
return;
38+
}
39+
};
40+
3341
return (
34-
<a href={imgPath} target="_blank" rel="noreferrer">
42+
<div onClick={handleClick} className="cursor-pointer">
3543
{/* eslint-disable-next-line @next/next/no-img-element */}
3644
<img
3745
src={src}
@@ -44,7 +52,7 @@ export function DocImageClient({
4452
className={className}
4553
{...props}
4654
/>
47-
</a>
55+
</div>
4856
);
4957
}
5058

src/components/imageLightbox.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,24 @@ export function ImageLightbox({
2525
const [open, setOpen] = useState(false);
2626

2727
const handleClick = (e: React.MouseEvent) => {
28-
// If Ctrl/Cmd+click, let the link handle it naturally (opens in new tab)
28+
// If Ctrl/Cmd+click, open image in new tab
2929
if (e.ctrlKey || e.metaKey) {
30-
// Allow default link behavior
30+
window.open(imgPath, '_blank', 'noreferrer');
3131
return;
3232
}
33-
// Normal click - prevent link navigation and open lightbox
34-
e.preventDefault();
33+
// Normal click - open lightbox
3534
setOpen(true);
3635
};
3736

3837
return (
3938
<Dialog.Root open={open} onOpenChange={setOpen}>
4039
{/* Custom trigger that handles modifier keys properly */}
41-
<a
42-
href={imgPath}
43-
target="_blank"
44-
rel="noreferrer"
40+
<div
4541
className="cursor-pointer border-none bg-transparent p-0 block w-full no-underline"
4642
onClick={handleClick}
4743
>
4844
{children}
49-
</a>
45+
</div>
5046

5147
<Dialog.Portal>
5248
<Dialog.Overlay className="image-lightbox-overlay fixed inset-0 bg-black/80 backdrop-blur-sm z-50" />

0 commit comments

Comments
 (0)