File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -277,6 +277,12 @@ const Modal = React.createClass({
277
277
}
278
278
} ,
279
279
280
+ componentWillUnmount ( ) {
281
+ if ( this . props . show ) {
282
+ this . onHide ( ) ;
283
+ }
284
+ } ,
285
+
280
286
onShow ( ) {
281
287
const doc = domUtils . ownerDocument ( this ) ;
282
288
const win = domUtils . ownerWindow ( this ) ;
Original file line number Diff line number Diff line change @@ -197,6 +197,22 @@ describe('Modal', function () {
197
197
, mountPoint ) ;
198
198
} ) ;
199
199
200
+ it ( 'Should unbind listeners when unmounted' , function ( ) {
201
+ render (
202
+ < div >
203
+ < Modal show onHide = { ( ) => null } animation = { false } >
204
+ < strong > Foo bar</ strong >
205
+ </ Modal >
206
+ </ div >
207
+ , mountPoint ) ;
208
+
209
+ assert . include ( document . body . className , 'modal-open' ) ;
210
+
211
+ render ( < div /> , mountPoint ) ;
212
+
213
+ assert . notInclude ( document . body . className , 'modal-open' ) ;
214
+ } ) ;
215
+
200
216
describe ( 'Focused state' , function ( ) {
201
217
let focusableContainer = null ;
202
218
You can’t perform that action at this time.
0 commit comments