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({
9
9
propTypes : {
10
10
isOpen : React . PropTypes . bool ,
11
11
onBlur : React . PropTypes . func ,
12
+ onOpen : React . PropTypes . func ,
12
13
closeTimeoutMS : React . PropTypes . number ,
13
14
closeOnBlur : React . PropTypes . bool ,
14
15
maintainFocus : React . PropTypes . bool
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ export default React.createClass({
54
54
overlayClassName : PropTypes . string ,
55
55
isOpen : PropTypes . bool ,
56
56
onBlur : PropTypes . func ,
57
+ onOpen : PropTypes . func ,
57
58
closeOnBlur : PropTypes . bool ,
58
59
closeTimeoutMS : PropTypes . number ,
59
60
children : PropTypes . any ,
@@ -129,6 +130,9 @@ export default React.createClass({
129
130
open ( ) {
130
131
focusManager . markForFocusLater ( ) ;
131
132
this . setState ( { isOpen : true } , ( ) => {
133
+ if ( this . props . onOpen ) {
134
+ this . props . onOpen ( ) ;
135
+ }
132
136
this . setState ( { afterOpen : true } ) ;
133
137
} ) ;
134
138
} ,
Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ describe('react-tray', function() {
48
48
} , 0 ) ;
49
49
} ) ;
50
50
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
+
51
57
it ( 'should close on overlay click' , function ( ) {
52
58
renderTray ( { isOpen : true , onBlur : function ( ) { } , closeTimeoutMS : 0 } ) ;
53
59
TestUtils . Simulate . click ( document . querySelector ( '.ReactTray__Overlay' ) ) ;
You can’t perform that action at this time.
0 commit comments