@@ -99,16 +99,6 @@ function renderNotifications(
9999 } ) ;
100100}
101101
102- function renderTooltip ( description : string ) {
103- return (
104- description !== '' && (
105- < EuiToolTip content = { description } delay = "regular" position = "right" >
106- < EuiIcon type = "iInCircle" />
107- </ EuiToolTip >
108- )
109- ) ;
110- }
111-
112102type EmbeddableWithDescription = IEmbeddable & { getDescription : ( ) => string } ;
113103
114104function getViewDescription ( embeddable : IEmbeddable | EmbeddableWithDescription ) {
@@ -134,9 +124,10 @@ export function PanelHeader({
134124 embeddable,
135125 headerId,
136126} : PanelHeaderProps ) {
137- const viewDescription = getViewDescription ( embeddable ) ;
138- const showTitle = ! hidePanelTitle && ( ! isViewMode || title || viewDescription !== '' ) ;
139- const showPanelBar = ! isViewMode || badges . length > 0 || notifications . length > 0 || showTitle ;
127+ const description = getViewDescription ( embeddable ) ;
128+ const showTitle = ! hidePanelTitle && ( ! isViewMode || title ) ;
129+ const showPanelBar =
130+ ! isViewMode || badges . length > 0 || notifications . length > 0 || showTitle || description ;
140131 const classes = classNames ( 'embPanel__header' , {
141132 // eslint-disable-next-line @typescript-eslint/naming-convention
142133 'embPanel__header--floater' : ! showPanelBar ,
@@ -174,26 +165,36 @@ export function PanelHeader({
174165 ) ;
175166 }
176167
168+ const renderTitle = ( ) => {
169+ const titleComponent = showTitle ? (
170+ < span className = { title ? 'embPanel__titleText' : 'embPanel__placeholderTitleText' } >
171+ { title || placeholderTitle }
172+ </ span >
173+ ) : undefined ;
174+ return description ? (
175+ < EuiToolTip
176+ content = { description }
177+ delay = "regular"
178+ position = "top"
179+ anchorClassName = "embPanel__titleTooltipAnchor"
180+ >
181+ < span className = "embPanel__titleInner" >
182+ { titleComponent } < EuiIcon type = "iInCircle" color = "subdued" />
183+ </ span >
184+ </ EuiToolTip >
185+ ) : (
186+ titleComponent
187+ ) ;
188+ } ;
189+
177190 return (
178191 < figcaption
179192 className = { classes }
180193 data-test-subj = { `embeddablePanelHeading-${ ( title || '' ) . replace ( / \s / g, '' ) } ` }
181194 >
182195 < h2 data-test-subj = "dashboardPanelTitle" className = "embPanel__title embPanel__dragger" >
183- { showTitle ? (
184- < span className = "embPanel__titleInner" >
185- < span
186- className = { title ? 'embPanel__titleText' : 'embPanel__placeholderTitleText' }
187- aria-hidden = "true"
188- >
189- { title || placeholderTitle }
190- </ span >
191- < EuiScreenReaderOnly > { getAriaLabel ( ) } </ EuiScreenReaderOnly >
192- { renderTooltip ( viewDescription ) }
193- </ span >
194- ) : (
195- < EuiScreenReaderOnly > { getAriaLabel ( ) } </ EuiScreenReaderOnly >
196- ) }
196+ < EuiScreenReaderOnly > { getAriaLabel ( ) } </ EuiScreenReaderOnly >
197+ { renderTitle ( ) }
197198 { renderBadges ( badges , embeddable ) }
198199 </ h2 >
199200 { renderNotifications ( notifications , embeddable ) }
0 commit comments