File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,27 @@ describe('State', () => {
100
100
expect ( document . querySelector ( '.ReactModalPortal' ) ) . toNotExist ( ) ;
101
101
} ) ;
102
102
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
+
103
124
it ( 'focuses the modal content' , ( ) => {
104
125
const modal = renderModal ( { isOpen : true } , null ) ;
105
126
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 {
140
140
this . portal . closeWithTimeout ( ) ;
141
141
}
142
142
143
- setTimeout ( ( ) => this . removePortal , closesAt - now ) ;
143
+ setTimeout ( this . removePortal , closesAt - now ) ;
144
144
} else {
145
145
this . removePortal ( ) ;
146
146
}
You can’t perform that action at this time.
0 commit comments