1- import { createContext , Fragment , useState } from 'react' ;
1+ import {
2+ AnchorHTMLAttributes ,
3+ cloneElement ,
4+ createContext ,
5+ Fragment ,
6+ useState ,
7+ } from 'react' ;
28import styled from '@emotion/styled' ;
39
410import Button from 'sentry/components/button' ;
@@ -54,9 +60,8 @@ type Props = {
5460 recentFirst : boolean ;
5561 stackTraceNotFound : boolean ;
5662 stackType : STACK_TYPE ;
57- title : React . ReactNode ;
63+ title : React . ReactElement < any , any > ;
5864 type : string ;
59- showPermalink ?: boolean ;
6065 wrapTitle ?: boolean ;
6166} ;
6267
@@ -67,7 +72,6 @@ export const TraceEventDataSectionContext = createContext<ChildProps | undefined
6772export function TraceEventDataSection ( {
6873 type,
6974 title,
70- showPermalink,
7175 wrapTitle,
7276 stackTraceNotFound,
7377 fullStackTrace,
@@ -192,18 +196,7 @@ export function TraceEventDataSection({
192196 type = { type }
193197 title = {
194198 < Header >
195- < Title >
196- { showPermalink ? (
197- < div >
198- < Permalink href = { '#' + type } className = "permalink" >
199- < StyledIconAnchor />
200- { title }
201- </ Permalink >
202- </ div >
203- ) : (
204- title
205- ) }
206- </ Title >
199+ < Title > { cloneElement ( title , { type} ) } </ Title >
207200 { ! stackTraceNotFound && (
208201 < Fragment >
209202 { ! state . display . includes ( 'raw-stack-trace' ) && (
@@ -282,6 +275,21 @@ export function TraceEventDataSection({
282275 ) ;
283276}
284277
278+ interface PermalinkTitleProps
279+ extends React . DetailedHTMLProps <
280+ AnchorHTMLAttributes < HTMLAnchorElement > ,
281+ HTMLAnchorElement
282+ > { }
283+
284+ export function PermalinkTitle ( props : PermalinkTitleProps ) {
285+ return (
286+ < Permalink { ...props } href = { '#' + props . type } className = "permalink" >
287+ < StyledIconAnchor />
288+ < h3 > { props . children } </ h3 >
289+ </ Permalink >
290+ ) ;
291+ }
292+
285293const StyledIconAnchor = styled ( IconAnchor ) `
286294 display: none;
287295 position: absolute;
@@ -292,7 +300,8 @@ const StyledIconAnchor = styled(IconAnchor)`
292300const Permalink = styled ( 'a' ) `
293301 display: inline-flex;
294302 justify-content: flex-start;
295- :hover ${ StyledIconAnchor } {
303+
304+ &:hover ${ StyledIconAnchor } {
296305 display: block;
297306 color: ${ p => p . theme . gray300 } ;
298307 }
0 commit comments