@@ -247,7 +247,8 @@ describe('Modal', function () {
247
247
equal ( modal . props . isOpen , true ) ;
248
248
var overlay = TestUtils . scryRenderedDOMComponentsWithClass ( modal . portal , 'ReactModal__Overlay' ) ;
249
249
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 ] ) ;
251
252
ok ( ! requestCloseCallback . called )
252
253
} ) ;
253
254
@@ -263,10 +264,49 @@ describe('Modal', function () {
263
264
equal ( modal . props . isOpen , true ) ;
264
265
var overlay = TestUtils . scryRenderedDOMComponentsWithClass ( modal . portal , 'ReactModal__Overlay' ) ;
265
266
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 ] ) ;
267
269
ok ( requestCloseCallback . called )
268
270
} ) ;
269
271
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
+
270
310
it ( 'should not stop event propagation' , function ( ) {
271
311
var hasPropagated = false
272
312
var modal = renderModal ( {
@@ -290,7 +330,8 @@ describe('Modal', function () {
290
330
equal ( modal . props . isOpen , true ) ;
291
331
var overlay = TestUtils . scryRenderedDOMComponentsWithClass ( modal . portal , 'ReactModal__Overlay' ) ;
292
332
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 ] ) ;
294
335
ok ( requestCloseCallback . called )
295
336
// Check if event is passed to onRequestClose callback.
296
337
var event = requestCloseCallback . getCall ( 0 ) . args [ 0 ] ;
0 commit comments