Skip to content
Merged
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
24 changes: 24 additions & 0 deletions src/utils/domUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// DOM utility functions
export function isElementInViewport(el: Element): boolean {
const rect = el.getBoundingClientRect();
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= window.innerHeight && rect.right <= window.innerWidth;
}
export function copyToClipboard(text: string): Promise<void> {
if (navigator.clipboard) return navigator.clipboard.writeText(text);
const textarea = document.createElement('textarea');
textarea.value = text;
textarea.style.position = 'fixed';
textarea.style.opacity = '0';
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 4, 2026

Choose a reason for hiding this comment

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

P2: The clipboard fallback always resolves even when copy fails, masking runtime failures and breaking error handling for callers.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/domUtils.ts, line 14:

<comment>The clipboard fallback always resolves even when copy fails, masking runtime failures and breaking error handling for callers.</comment>

<file context>
@@ -0,0 +1,24 @@
+  textarea.style.opacity = '0';
+  document.body.appendChild(textarea);
+  textarea.select();
+  document.execCommand('copy');
+  document.body.removeChild(textarea);
+  return Promise.resolve();
</file context>
Fix with Cubic

document.body.removeChild(textarea);
return Promise.resolve();
}
export function getScrollPercentage(): number {
const h = document.documentElement;
const b = document.body;
const scrollTop = h.scrollTop || b.scrollTop;
const scrollHeight = (h.scrollHeight || b.scrollHeight) - h.clientHeight;
return scrollHeight > 0 ? Math.round((scrollTop / scrollHeight) * 100) : 0;
}
Loading