@@ -247,7 +247,8 @@ describe('Modal', function () {
247247 equal ( modal . props . isOpen , true ) ;
248248 var overlay = TestUtils . scryRenderedDOMComponentsWithClass ( modal . portal , 'ReactModal__Overlay' ) ;
249249 equal ( overlay . length , 1 ) ;
250- Simulate . click ( overlay [ 0 ] ) ; // click the overlay
250+ Simulate . mouseDown ( overlay [ 0 ] ) ; // click the overlay
251+ Simulate . mouseUp ( overlay [ 0 ] ) ;
251252 ok ( ! requestCloseCallback . called )
252253 } ) ;
253254
@@ -263,10 +264,49 @@ describe('Modal', function () {
263264 equal ( modal . props . isOpen , true ) ;
264265 var overlay = TestUtils . scryRenderedDOMComponentsWithClass ( modal . portal , 'ReactModal__Overlay' ) ;
265266 equal ( overlay . length , 1 ) ;
266- Simulate . click ( overlay [ 0 ] ) ; // click the overlay
267+ Simulate . mouseDown ( overlay [ 0 ] ) ; // click the overlay
268+ Simulate . mouseUp ( overlay [ 0 ] ) ;
267269 ok ( requestCloseCallback . called )
268270 } ) ;
269271
272+ it ( 'verify overlay mouse down and content mouse up when shouldCloseOnOverlayClick sets to true' , function ( ) {
273+ var requestCloseCallback = sinon . spy ( ) ;
274+ var modal = renderModal ( {
275+ isOpen : true ,
276+ shouldCloseOnOverlayClick : true ,
277+ onRequestClose : function ( ) {
278+ requestCloseCallback ( ) ;
279+ }
280+ } ) ;
281+ equal ( modal . props . isOpen , true ) ;
282+ var overlay = TestUtils . scryRenderedDOMComponentsWithClass ( modal . portal , 'ReactModal__Overlay' ) ;
283+ var content = TestUtils . scryRenderedDOMComponentsWithClass ( modal . portal , 'ReactModal__Content' ) ;
284+ equal ( overlay . length , 1 ) ;
285+ equal ( content . length , 1 ) ;
286+ Simulate . mouseDown ( overlay [ 0 ] ) ; // click the overlay
287+ Simulate . mouseUp ( content [ 0 ] ) ;
288+ ok ( ! requestCloseCallback . called )
289+ } ) ;
290+
291+ it ( 'verify content mouse down and overlay mouse up when shouldCloseOnOverlayClick sets to true' , function ( ) {
292+ var requestCloseCallback = sinon . spy ( ) ;
293+ var modal = renderModal ( {
294+ isOpen : true ,
295+ shouldCloseOnOverlayClick : true ,
296+ onRequestClose : function ( ) {
297+ requestCloseCallback ( ) ;
298+ }
299+ } ) ;
300+ equal ( modal . props . isOpen , true ) ;
301+ var overlay = TestUtils . scryRenderedDOMComponentsWithClass ( modal . portal , 'ReactModal__Overlay' ) ;
302+ var content = TestUtils . scryRenderedDOMComponentsWithClass ( modal . portal , 'ReactModal__Content' ) ;
303+ equal ( content . length , 1 ) ;
304+ equal ( overlay . length , 1 ) ;
305+ Simulate . mouseDown ( content [ 0 ] ) ; // click the overlay
306+ Simulate . mouseUp ( overlay [ 0 ] ) ;
307+ ok ( ! requestCloseCallback . called )
308+ } ) ;
309+
270310 it ( 'should not stop event propagation' , function ( ) {
271311 var hasPropagated = false
272312 var modal = renderModal ( {
@@ -290,7 +330,8 @@ describe('Modal', function () {
290330 equal ( modal . props . isOpen , true ) ;
291331 var overlay = TestUtils . scryRenderedDOMComponentsWithClass ( modal . portal , 'ReactModal__Overlay' ) ;
292332 equal ( overlay . length , 1 ) ;
293- Simulate . click ( overlay [ 0 ] ) ; // click the overlay
333+ Simulate . mouseDown ( overlay [ 0 ] ) ; // click the overlay
334+ Simulate . mouseUp ( overlay [ 0 ] ) ;
294335 ok ( requestCloseCallback . called )
295336 // Check if event is passed to onRequestClose callback.
296337 var event = requestCloseCallback . getCall ( 0 ) . args [ 0 ] ;
0 commit comments