Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit 46dc158

Browse files
Improve breadcrumbs copy (#689)
1 parent 222e8f7 commit 46dc158

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

client/src/components/Breadcrumbs/index.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import {
22
Fragment,
33
MouseEvent,
44
ReactElement,
5+
useCallback,
56
useEffect,
67
useRef,
78
useState,
9+
ClipboardEvent,
810
} from 'react';
911
import { Range } from '../../types/results';
12+
import { copyToClipboard, isWindowsPath } from '../../utils';
1013
import BreadcrumbSection from './BreadcrumbSection';
1114
import BreadcrumbsCollapsed from './BreadcrumbsCollapsed';
1215

@@ -32,6 +35,7 @@ const Breadcrumbs = ({
3235
separator = '/',
3336
type = 'link',
3437
limitSectionWidth,
38+
path,
3539
}: Props) => {
3640
const containerRef = useRef<HTMLDivElement>(null);
3741
const [formattedPathParts, setFormattedPathParts] =
@@ -75,8 +79,26 @@ const Breadcrumbs = ({
7579
setFormattedPathParts(partsToShow);
7680
}, [pathParts]);
7781

82+
const onCopy = useCallback(
83+
(e: ClipboardEvent<HTMLDivElement>) => {
84+
e.preventDefault();
85+
copyToClipboard(
86+
document
87+
.getSelection()
88+
?.toString()
89+
.split(separator)
90+
.map((part) => part.trim())
91+
.join(isWindowsPath(path) ? '\\' : '/') || '',
92+
);
93+
},
94+
[path],
95+
);
96+
7897
return (
79-
<div className="flex items-center body-s flex-shrink-0 gap-1.5">
98+
<div
99+
className="flex items-center body-s flex-shrink-0 gap-1.5"
100+
onCopy={onCopy}
101+
>
80102
{/* this div is hidden and used only to calculate the full width of breadcrumbs before truncation */}
81103
<div
82104
className="fixed top-full opacity-0 left-0 flex flex-nowrap items-center body-s flex-shrink-0 gap-1.5 select-none"

client/src/components/ReportBugModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const ReportBugModal = ({
9090
}
9191
setSubmitted(true);
9292
},
93-
[],
93+
[form, envConfig.tracking_id],
9494
);
9595
const resetState = useCallback(() => {
9696
if (serverCrashedMessage) {

0 commit comments

Comments
 (0)