Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,40 @@
return isGraphTooltipDocked ? setIsDocked(false) : setIsDocked(true);
};
const handleCopyItem = (text: string): void => {
void navigator.clipboard.writeText(text);
if (navigator.clipboard?.writeText) {

Check failure on line 111 in ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx

View workflow job for this annotation

GitHub Actions / UI Test and Lint

Unexpected object value in conditional. The condition is always true
void navigator.clipboard.writeText(text).catch(() => {
// Fallback to legacy method if modern API fails
copyWithLegacyMethod(text);
});
} else {
// Use legacy method if modern API not available
copyWithLegacyMethod(text);
}
};

const copyWithLegacyMethod = (text: string): void => {
const textArea = document.createElement('textarea');
textArea.value = text;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();

let successful = false;
try {
successful = document.execCommand('copy');
} catch {
// Copy failed
} finally {
document.body.removeChild(textArea);
}

if (!successful) {
alert(
'Copy failed. Please copy manually: ' +
text.substring(0, 100) +
(text.length > 100 ? '...' : '')
);
}
};

const functionName =
Expand Down
Loading