File tree Expand file tree Collapse file tree 5 files changed +16
-4
lines changed Expand file tree Collapse file tree 5 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -167,11 +167,14 @@ function App() {
167167 </ div >
168168
169169 < div style = { { marginTop : '1rem' } } >
170- < button id = "buttonAfterShow " > Check the dev console</ button >
170+ < button id = "buttonCallbacks " > Check the dev console</ button >
171171 < Tooltip
172172 place = "bottom"
173- anchorId = "buttonAfterShow"
174- afterShow = { ( ) => console . log ( 'Hello world' ) }
173+ anchorId = "buttonCallbacks"
174+ // eslint-disable-next-line no-console
175+ afterShow = { ( ) => console . log ( 'After show' ) }
176+ // eslint-disable-next-line no-console
177+ afterHide = { ( ) => console . log ( 'After hide' ) }
175178 content = "Showing tooltip and calling afterShow method"
176179 />
177180 </ div >
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ const Tooltip = ({
2828 style : externalStyles ,
2929 position,
3030 afterShow,
31+ afterHide,
3132 // props handled by controller
3233 isHtmlContent = false ,
3334 content,
@@ -54,9 +55,13 @@ const Tooltip = ({
5455 setShow ( value )
5556 }
5657
57- if ( value && afterShow ) {
58+ // Callbacks
59+ if ( value === true && afterShow ) {
5860 afterShow ( )
5961 }
62+ if ( value === false && afterHide ) {
63+ afterHide ( )
64+ }
6065 }
6166
6267 const handleShowTooltipDelayed = ( ) => {
Original file line number Diff line number Diff line change @@ -55,4 +55,5 @@ export interface ITooltip {
5555 isOpen ?: boolean
5656 setIsOpen ?: ( value : boolean ) => void
5757 afterShow ?: ( ) => void
58+ afterHide ?: ( ) => void
5859}
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ const TooltipController = ({
3636 isOpen,
3737 setIsOpen,
3838 afterShow,
39+ afterHide,
3940} : ITooltipController ) => {
4041 const [ tooltipContent , setTooltipContent ] = useState ( content || html )
4142 const [ tooltipPlace , setTooltipPlace ] = useState ( place )
@@ -192,6 +193,7 @@ const TooltipController = ({
192193 isOpen,
193194 setIsOpen,
194195 afterShow,
196+ afterHide,
195197 }
196198
197199 return children ? < Tooltip { ...props } > { children } </ Tooltip > : < Tooltip { ...props } />
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ export interface ITooltipController {
3434 isOpen ?: boolean
3535 setIsOpen ?: ( value : boolean ) => void
3636 afterShow ?: ( ) => void
37+ afterHide ?: ( ) => void
3738}
3839
3940declare module 'react' {
You can’t perform that action at this time.
0 commit comments