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() {
165
165
/>
166
166
</ div >
167
167
</ 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 >
168
178
</ main >
169
179
)
170
180
}
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ const Tooltip = ({
27
27
clickable = false ,
28
28
style : externalStyles ,
29
29
position,
30
+ afterShow,
30
31
// props handled by controller
31
32
isHtmlContent = false ,
32
33
content,
@@ -52,6 +53,10 @@ const Tooltip = ({
52
53
} else if ( isOpen === undefined ) {
53
54
setShow ( value )
54
55
}
56
+
57
+ if ( value && afterShow ) {
58
+ afterShow ( )
59
+ }
55
60
}
56
61
57
62
const handleShowTooltipDelayed = ( ) => {
Original file line number Diff line number Diff line change @@ -54,4 +54,5 @@ export interface ITooltip {
54
54
position ?: IPosition
55
55
isOpen ?: boolean
56
56
setIsOpen ?: ( value : boolean ) => void
57
+ afterShow ?: ( ) => void
57
58
}
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ const TooltipController = ({
35
35
position,
36
36
isOpen,
37
37
setIsOpen,
38
+ afterShow,
38
39
} : ITooltipController ) => {
39
40
const [ tooltipContent , setTooltipContent ] = useState ( content || html )
40
41
const [ tooltipPlace , setTooltipPlace ] = useState ( place )
@@ -190,6 +191,7 @@ const TooltipController = ({
190
191
position,
191
192
isOpen,
192
193
setIsOpen,
194
+ afterShow,
193
195
}
194
196
195
197
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 {
33
33
position ?: IPosition
34
34
isOpen ?: boolean
35
35
setIsOpen ?: ( value : boolean ) => void
36
+ afterShow ?: ( ) => void
36
37
}
37
38
38
39
declare module 'react' {
You can’t perform that action at this time.
0 commit comments