File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -296,6 +296,10 @@ const Modal = React.createClass({
296296 addFocusListener ( this . enforceFocus ) ;
297297
298298 this . focus ( ) ;
299+
300+ if ( this . props . onShow ) {
301+ this . props . onShow ( ) ;
302+ }
299303 } ,
300304
301305 onHide ( ) {
Original file line number Diff line number Diff line change @@ -261,6 +261,30 @@ describe('Modal', function () {
261261 , mountPoint ) ;
262262 } ) ;
263263
264+ it ( 'Should fire show callback on mount' , function ( ) {
265+ let onShowSpy = sinon . spy ( ) ;
266+ render (
267+ < Modal show onShow = { onShowSpy } >
268+ < strong > Message</ strong >
269+ </ Modal >
270+ , mountPoint ) ;
271+
272+ expect ( onShowSpy ) . to . have . been . calledOnce ;
273+ } ) ;
274+
275+ it ( 'Should fire show callback on update' , function ( ) {
276+ let onShowSpy = sinon . spy ( ) ;
277+ let instance = render (
278+ < Modal onShow = { onShowSpy } >
279+ < strong > Message</ strong >
280+ </ Modal >
281+ , mountPoint ) ;
282+
283+ instance . renderWithProps ( { show : true } ) ;
284+
285+ expect ( onShowSpy ) . to . have . been . calledOnce ;
286+ } ) ;
287+
264288 describe ( 'Focused state' , function ( ) {
265289 let focusableContainer = null ;
266290
You can’t perform that action at this time.
0 commit comments