This repository was archived by the owner on Jan 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff 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' ;
911import { Range } from '../../types/results' ;
12+ import { copyToClipboard , isWindowsPath } from '../../utils' ;
1013import BreadcrumbSection from './BreadcrumbSection' ;
1114import 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"
Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments