Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/console/src/components/documents/PDFPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ export function PDFPreview({ src, name }: { src: string; name?: string }) {
}
};

const handleDownload = () => {
const link = document.createElement("a");
link.href = src;
link.download = name || "document.pdf";
link.click();
Copy link

@cubic-dev-ai cubic-dev-ai bot Oct 31, 2025

Choose a reason for hiding this comment

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

Programmatic download fails in browsers like Firefox because the anchor is never added to the DOM before click(). Attach it to document.body before triggering the click and remove it afterward.

Prompt for AI agents
Address the following comment on apps/console/src/components/documents/PDFPreview.tsx at line 78:

<comment>Programmatic download fails in browsers like Firefox because the anchor is never added to the DOM before click(). Attach it to document.body before triggering the click and remove it afterward.</comment>

<file context>
@@ -71,6 +71,13 @@ export function PDFPreview({ src, name }: { src: string; name?: string }) {
+    const link = document.createElement(&quot;a&quot;);
+    link.href = src;
+    link.download = name || &quot;document.pdf&quot;;
+    link.click();
+  };
+
</file context>
Fix with Cubic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works fine in firefox

};

return (
<div className="grid grid-rows-[max-content_1fr] h-full bg-subtle">
{/* Custom Zoom Controls */}
Expand All @@ -97,7 +104,7 @@ export function PDFPreview({ src, name }: { src: string; name?: string }) {
<button onClick={zoomFactor(1.2)} className={btnClass}>
<IconPlusLarge size={16} />
</button>
<button onClick={zoomFactor(1.2)} className={btnClass}>
<button onClick={handleDownload} className={btnClass}>
<IconArrowInbox size={16} />
</button>
</nav>
Expand Down
9 changes: 8 additions & 1 deletion apps/trust/src/components/PDFPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ export function PDFPreview({ src, name }: { src: string; name?: string }) {
}
};

const handleDownload = () => {
const link = document.createElement("a");
link.href = src;
link.download = name || "document.pdf";
link.click();
};

return (
<div className="grid grid-rows-[max-content_1fr] h-full bg-subtle">
{/* Custom Zoom Controls */}
Expand All @@ -97,7 +104,7 @@ export function PDFPreview({ src, name }: { src: string; name?: string }) {
<button onClick={zoomFactor(1.2)} className={btnClass}>
<IconPlusLarge size={16} />
</button>
<button onClick={zoomFactor(1.2)} className={btnClass}>
<button onClick={handleDownload} className={btnClass}>
<IconArrowInbox size={16} />
</button>
</nav>
Expand Down