File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,27 @@ describe('State', () => {
100100 expect ( document . querySelector ( '.ReactModalPortal' ) ) . toNotExist ( ) ;
101101 } ) ;
102102
103+ it ( 'removes the portal node after closeTimeoutMS' , done => {
104+ const closeTimeoutMS = 100 ;
105+ renderModal ( { isOpen : true , closeTimeoutMS } , 'hello' ) ;
106+
107+ function checkDOM ( count ) {
108+ const portal = document . querySelectorAll ( '.ReactModalPortal' ) ;
109+ expect ( portal . length ) . toBe ( count ) ;
110+ }
111+
112+ unmountModal ( ) ;
113+
114+ // content is still mounted after modal is gone
115+ checkDOM ( 1 ) ;
116+
117+ setTimeout ( ( ) => {
118+ // content is unmounted after specified timeout
119+ checkDOM ( 0 ) ;
120+ done ( ) ;
121+ } , closeTimeoutMS ) ;
122+ } ) ;
123+
103124 it ( 'focuses the modal content' , ( ) => {
104125 const modal = renderModal ( { isOpen : true } , null ) ;
105126 expect ( document . activeElement ) . toBe ( mcontent ( modal ) ) ;
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ export default class Modal extends Component {
140140 this . portal . closeWithTimeout ( ) ;
141141 }
142142
143- setTimeout ( ( ) => this . removePortal , closesAt - now ) ;
143+ setTimeout ( this . removePortal , closesAt - now ) ;
144144 } else {
145145 this . removePortal ( ) ;
146146 }
You can’t perform that action at this time.
0 commit comments