File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 1
- import React from 'react' ;
1
+ import React , { useState } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
3
import { omit } from 'ramda' ;
4
4
import { Fade as RSFade } from 'reactstrap' ;
@@ -17,12 +17,18 @@ const Fade = props => {
17
17
style,
18
18
...otherProps
19
19
} = props ;
20
+
21
+ // set visibility to hidden after transition has completed to hide tooltips
22
+ const [ hidden , setHidden ] = useState ( ! is_in ) ;
23
+
20
24
return (
21
25
< RSFade
22
26
baseClass = { base_class }
23
27
baseClassActive = { base_class_active }
24
28
in = { is_in }
25
- style = { is_in ? style : { visibility : 'hidden' , ...style } }
29
+ style = { hidden ? { visibility : 'hidden' , ...style } : style }
30
+ onEnter = { ( ) => setHidden ( false ) }
31
+ onExited = { ( ) => setHidden ( true ) }
26
32
{ ...omit ( [ 'setProps' ] , otherProps ) }
27
33
data-dash-is-loading = {
28
34
( loading_state && loading_state . is_loading ) || undefined
Original file line number Diff line number Diff line change @@ -24,8 +24,22 @@ describe('Fade', () => {
24
24
fade . rerender ( < Fade is_in /> ) ;
25
25
jest . runAllTimers ( ) ;
26
26
27
- expect ( fade . container . querySelector ( 'div.fade.show' ) ) . not . toBe (
28
- null
29
- ) ;
27
+ expect ( fade . container . querySelector ( 'div.fade.show' ) ) . not . toBe ( null ) ;
28
+ } ) ;
29
+
30
+ test ( 'sets visibility hidden when is_in is false and not transitioning' , ( ) => {
31
+ const fade = render ( < Fade is_in = { false } timeout = { 1000 } /> ) ;
32
+
33
+ expect ( fade . container . firstChild ) . toHaveStyle ( 'visibility:hidden' ) ;
34
+
35
+ fade . rerender ( < Fade is_in timeout = { 1000 } /> ) ;
36
+ expect ( fade . container . firstChild ) . not . toHaveStyle ( 'visibility:hidden' ) ;
37
+ jest . runAllTimers ( ) ;
38
+ expect ( fade . container . firstChild ) . not . toHaveStyle ( 'visibility:hidden' ) ;
39
+
40
+ fade . rerender ( < Fade is_in = { false } timout = { 1000 } /> ) ;
41
+ expect ( fade . container . firstChild ) . not . toHaveStyle ( 'visibility:hidden' ) ;
42
+ jest . runAllTimers ( ) ;
43
+ expect ( fade . container . firstChild ) . toHaveStyle ( 'visibility:hidden' ) ;
30
44
} ) ;
31
45
} ) ;
You can’t perform that action at this time.
0 commit comments