File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -277,6 +277,12 @@ const Modal = React.createClass({
277277 }
278278 } ,
279279
280+ componentWillUnmount ( ) {
281+ if ( this . props . show ) {
282+ this . onHide ( ) ;
283+ }
284+ } ,
285+
280286 onShow ( ) {
281287 const doc = domUtils . ownerDocument ( this ) ;
282288 const win = domUtils . ownerWindow ( this ) ;
Original file line number Diff line number Diff line change @@ -197,6 +197,22 @@ describe('Modal', function () {
197197 , mountPoint ) ;
198198 } ) ;
199199
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+
200216 describe ( 'Focused state' , function ( ) {
201217 let focusableContainer = null ;
202218
You can’t perform that action at this time.
0 commit comments