Skip to content

Commit dd3fe50

Browse files
committed
fix(files): linked images don't open a tab on a plain click in the editor
The linked-image anchor's native navigation was firing on a plain click in edit mode (where handleClick intentionally returns false for caret placement). Prevent the anchor's default so the editor's handleClick — gated on editable/modifier, matching text links via openOnClick:false — is the sole navigator.
1 parent 26f9fc5 commit dd3fe50

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/image.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,16 @@ function ResizableImageView({ node, updateAttributes, selected, editor }: ReactN
248248
return (
249249
<NodeViewWrapper className='relative my-4 inline-block leading-none'>
250250
{safeHref ? (
251-
<a href={safeHref} target='_blank' rel='noopener noreferrer' className='block'>
251+
// The editor's handleClick is the sole navigator (gated on editable/modifier, like text links
252+
// via openOnClick:false): prevent the anchor's own navigation so a plain click in edit mode
253+
// places the caret / selects the node instead of opening a tab.
254+
<a
255+
href={safeHref}
256+
target='_blank'
257+
rel='noopener noreferrer'
258+
className='block'
259+
onClick={(event) => event.preventDefault()}
260+
>
252261
{image}
253262
</a>
254263
) : (

0 commit comments

Comments
 (0)