File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export default React.createClass({
99 propTypes : {
1010 isOpen : React . PropTypes . bool ,
1111 onBlur : React . PropTypes . func ,
12+ onOpen : React . PropTypes . func ,
1213 closeTimeoutMS : React . PropTypes . number ,
1314 closeOnBlur : React . PropTypes . bool ,
1415 maintainFocus : React . PropTypes . bool
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ export default React.createClass({
5454 overlayClassName : PropTypes . string ,
5555 isOpen : PropTypes . bool ,
5656 onBlur : PropTypes . func ,
57+ onOpen : PropTypes . func ,
5758 closeOnBlur : PropTypes . bool ,
5859 closeTimeoutMS : PropTypes . number ,
5960 children : PropTypes . any ,
@@ -129,6 +130,9 @@ export default React.createClass({
129130 open ( ) {
130131 focusManager . markForFocusLater ( ) ;
131132 this . setState ( { isOpen : true } , ( ) => {
133+ if ( this . props . onOpen ) {
134+ this . props . onOpen ( ) ;
135+ }
132136 this . setState ( { afterOpen : true } ) ;
133137 } ) ;
134138 } ,
Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ describe('react-tray', function() {
4848 } , 0 ) ;
4949 } ) ;
5050
51+ it ( 'should call onOpen when it opens' , function ( ) {
52+ let calledOpen = false ;
53+ renderTray ( { isOpen : true , onOpen : function ( ) { calledOpen = true ; } } ) ;
54+ equal ( calledOpen , true ) ;
55+ } ) ;
56+
5157 it ( 'should close on overlay click' , function ( ) {
5258 renderTray ( { isOpen : true , onBlur : function ( ) { } , closeTimeoutMS : 0 } ) ;
5359 TestUtils . Simulate . click ( document . querySelector ( '.ReactTray__Overlay' ) ) ;
You can’t perform that action at this time.
0 commit comments