File tree Expand file tree Collapse file tree 5 files changed +19
-0
lines changed Expand file tree Collapse file tree 5 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,16 @@ function App() {
165165 />
166166 </ div >
167167 </ div >
168+
169+ < div style = { { marginTop : '1rem' } } >
170+ < button id = "buttonAfterShow" > Check the dev console</ button >
171+ < Tooltip
172+ place = "bottom"
173+ anchorId = "buttonAfterShow"
174+ afterShow = { ( ) => console . log ( 'Hello world' ) }
175+ content = "Showing tooltip and calling afterShow method"
176+ />
177+ </ div >
168178 </ main >
169179 )
170180}
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ const Tooltip = ({
2727 clickable = false ,
2828 style : externalStyles ,
2929 position,
30+ afterShow,
3031 // props handled by controller
3132 isHtmlContent = false ,
3233 content,
@@ -52,6 +53,10 @@ const Tooltip = ({
5253 } else if ( isOpen === undefined ) {
5354 setShow ( value )
5455 }
56+
57+ if ( value && afterShow ) {
58+ afterShow ( )
59+ }
5560 }
5661
5762 const handleShowTooltipDelayed = ( ) => {
Original file line number Diff line number Diff line change @@ -54,4 +54,5 @@ export interface ITooltip {
5454 position ?: IPosition
5555 isOpen ?: boolean
5656 setIsOpen ?: ( value : boolean ) => void
57+ afterShow ?: ( ) => void
5758}
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ const TooltipController = ({
3535 position,
3636 isOpen,
3737 setIsOpen,
38+ afterShow,
3839} : ITooltipController ) => {
3940 const [ tooltipContent , setTooltipContent ] = useState ( content || html )
4041 const [ tooltipPlace , setTooltipPlace ] = useState ( place )
@@ -190,6 +191,7 @@ const TooltipController = ({
190191 position,
191192 isOpen,
192193 setIsOpen,
194+ afterShow,
193195 }
194196
195197 return children ? < Tooltip { ...props } > { children } </ Tooltip > : < Tooltip { ...props } />
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export interface ITooltipController {
3333 position ?: IPosition
3434 isOpen ?: boolean
3535 setIsOpen ?: ( value : boolean ) => void
36+ afterShow ?: ( ) => void
3637}
3738
3839declare module 'react' {
You can’t perform that action at this time.
0 commit comments