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' ;
22import PropTypes from 'prop-types' ;
33import { omit } from 'ramda' ;
44import { Fade as RSFade } from 'reactstrap' ;
@@ -17,12 +17,18 @@ const Fade = props => {
1717 style,
1818 ...otherProps
1919 } = props ;
20+
21+ // set visibility to hidden after transition has completed to hide tooltips
22+ const [ hidden , setHidden ] = useState ( ! is_in ) ;
23+
2024 return (
2125 < RSFade
2226 baseClass = { base_class }
2327 baseClassActive = { base_class_active }
2428 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 ) }
2632 { ...omit ( [ 'setProps' ] , otherProps ) }
2733 data-dash-is-loading = {
2834 ( loading_state && loading_state . is_loading ) || undefined
Original file line number Diff line number Diff line change @@ -24,8 +24,22 @@ describe('Fade', () => {
2424 fade . rerender ( < Fade is_in /> ) ;
2525 jest . runAllTimers ( ) ;
2626
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' ) ;
3044 } ) ;
3145} ) ;
You can’t perform that action at this time.
0 commit comments