File tree Expand file tree Collapse file tree 2 files changed +32
-7
lines changed Expand file tree Collapse file tree 2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,30 @@ function App() {
177177 afterHide = { ( ) => console . log ( 'After hide' ) }
178178 content = "Showing tooltip and calling afterShow method"
179179 />
180+
181+ < button id = "buttonCallbacksClick" > With click event</ button >
182+ < Tooltip
183+ events = { [ 'click' ] }
184+ place = "bottom"
185+ anchorId = "buttonCallbacksClick"
186+ // eslint-disable-next-line no-console
187+ afterShow = { ( ) => console . log ( 'After show with click' ) }
188+ // eslint-disable-next-line no-console
189+ afterHide = { ( ) => console . log ( 'After hide with click' ) }
190+ content = "Showing tooltip and calling afterShow method"
191+ />
192+
193+ < button id = "buttonCallbacksDelay" > With delay</ button >
194+ < Tooltip
195+ delayShow = { 1000 }
196+ place = "bottom"
197+ anchorId = "buttonCallbacksDelay"
198+ // eslint-disable-next-line no-console
199+ afterShow = { ( ) => console . log ( 'After show with delay' ) }
200+ // eslint-disable-next-line no-console
201+ afterHide = { ( ) => console . log ( 'After hide with delay' ) }
202+ content = "Showing tooltip and calling afterShow method"
203+ />
180204 </ div >
181205 </ main >
182206 )
Original file line number Diff line number Diff line change @@ -54,15 +54,16 @@ const Tooltip = ({
5454 } else if ( isOpen === undefined ) {
5555 setShow ( value )
5656 }
57+ }
5758
58- // Callbacks
59- if ( value === true && afterShow ) {
60- afterShow ( )
61- }
62- if ( value === false && afterHide ) {
63- afterHide ( )
59+ // Callbacks
60+ useEffect ( ( ) => {
61+ if ( show ) {
62+ afterShow ?. ( )
63+ } else {
64+ afterHide ?. ( )
6465 }
65- }
66+ } , [ show ] )
6667
6768 const handleShowTooltipDelayed = ( ) => {
6869 if ( tooltipShowDelayTimerRef . current ) {
You can’t perform that action at this time.
0 commit comments