From 60c77d4af684b999ab411cfe568381309abed531 Mon Sep 17 00:00:00 2001 From: Haoning-Sun Date: Wed, 12 Nov 2025 12:10:21 +0800 Subject: [PATCH 1/2] Fixes copy failure when accessing Parca UI via IP address --- .../FlameGraphArrow/ContextMenu.tsx | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx b/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx index 4a119f4bad7..542a15e74b9 100644 --- a/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +++ b/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx @@ -108,7 +108,36 @@ const ContextMenu = ({ return isGraphTooltipDocked ? setIsDocked(false) : setIsDocked(true); }; const handleCopyItem = (text: string): void => { - void navigator.clipboard.writeText(text); + if (navigator.clipboard?.writeText) { + 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 = From c3d7ea7b09a7d7b3fbdc405bcc56f3d111aee0a8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 04:55:46 +0000 Subject: [PATCH 2/2] [pre-commit.ci lite] apply automatic fixes --- .../src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx b/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx index 542a15e74b9..18b4102ed02 100644 --- a/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +++ b/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx @@ -136,7 +136,11 @@ const ContextMenu = ({ } if (!successful) { - alert('Copy failed. Please copy manually: ' + text.substring(0, 100) + (text.length > 100 ? '...' : '')); + alert( + 'Copy failed. Please copy manually: ' + + text.substring(0, 100) + + (text.length > 100 ? '...' : '') + ); } };