11import React , {
22 FC ,
3- FocusEvent ,
43 ComponentType ,
54 HTMLAttributes ,
65 ReactElement ,
@@ -12,15 +11,13 @@ import React, {
1211 useRef ,
1312 useState ,
1413 useEffect ,
15- useCallback ,
1614} from 'react' ;
1715import classnames from 'classnames' ;
1816import { registerStyle } from './util' ;
1917import { DropdownButton , DropdownButtonProps } from './DropdownButton' ;
2018import { useControlledValue , useEventCallback } from './hooks' ;
2119import { Bivariant } from './typeUtils' ;
22- import { Button } from './Button' ;
23- import { Popover } from './Popover' ;
20+ import { TooltipContent } from './TooltipContent' ;
2421
2522/**
2623 *
@@ -99,38 +96,6 @@ const TabMenu: FC<TabMenuProps> = (props) => {
9996 ) ;
10097} ;
10198
102- /**
103- *
104- */
105- const TooltipContent = ( props : { children : ReactNode ; icon ?: string } ) => {
106- const { children, icon = 'info' } = props ;
107- const [ isHideTooltip , setIsHideTooltip ] = useState ( true ) ;
108- const popoverRef = useRef < HTMLDivElement > ( null ) ;
109- const tooltipToggle = useCallback ( ( ) => {
110- setIsHideTooltip ( ( hidden ) => ! hidden ) ;
111- } , [ ] ) ;
112- const onBlur = useCallback ( ( e : FocusEvent < HTMLElement > ) => {
113- if ( ! popoverRef . current ?. contains ( e . relatedTarget ) ) {
114- setIsHideTooltip ( true ) ;
115- }
116- } , [ ] ) ;
117- return (
118- < span className = 'slds-dropdown-trigger react-slds-tooltip-content' >
119- < Button type = 'icon' icon = { icon } onClick = { tooltipToggle } onBlur = { onBlur } />
120- < Popover
121- ref = { popoverRef }
122- hidden = { isHideTooltip }
123- tabIndex = { - 1 }
124- onBlur = { onBlur }
125- offsetX = { - 15 }
126- tooltip
127- >
128- { children }
129- </ Popover >
130- </ span >
131- ) ;
132- } ;
133-
13499/**
135100 *
136101 */
@@ -325,7 +290,7 @@ function useInitComponentStyle() {
325290 ] ,
326291 [ '.react-slds-tab-menu' , '{ position: absolute; top: 0; right: 0; }' ] ,
327292 [
328- '.react-slds-tooltip-content' ,
293+ '.slds-tabs__item.react-slds-tab-with-menu .react-slds-tab-item-content . react-slds-tooltip-content' ,
329294 '{ position: absolute; top: 0.6rem; right: 2.25rem; }' ,
330295 ] ,
331296 [
0 commit comments