]> source.dussan.org Git - jquery-ui.git/commitdiff
Mouse: Don't stop propagation of mouseup 1621/head
authorHannah Methvin <hannahmethvin@gmail.com>
Sun, 18 Oct 2015 16:36:43 +0000 (12:36 -0400)
committerHannah Methvin <hannahmethvin@gmail.com>
Sun, 18 Oct 2015 16:36:43 +0000 (12:36 -0400)
Fixes #10818

tests/unit/draggable/core.js
ui/widgets/draggable.js
ui/widgets/mouse.js

index 8bc751e0ebef694a26cadef0890cc612393eef80..9efe9d3f19277d394515c05f732c64bd27fd2221 100644 (file)
@@ -345,4 +345,21 @@ test( "ui-draggable-handle managed correctly in nested draggables", function( as
        assert.hasClasses( child, "ui-draggable-handle", "child retains class name on destroy" );
 } );
 
+test( "does not stop propagation to window", function( assert ) {
+       expect( 1 );
+       var element = $( "#draggable1" ).draggable();
+
+       var handler = function() {
+               assert.ok( true, "mouseup propagates to window" );
+       };
+       $( window ).on( "mouseup", handler );
+
+       element.simulate( "drag", {
+               dx: 10,
+               dy: 10
+       } );
+
+       $( window ).off( "mouseup", handler );
+} );
+
 } );
index f61c38ce0a3a776c54b3d9a8d95960861eff7447..b459afe00464dc38d38c0b781b953aa32e9a5f15 100644 (file)
@@ -255,7 +255,7 @@ $.widget( "ui.draggable", $.ui.mouse, {
                if ( !noPropagation ) {
                        var ui = this._uiHash();
                        if ( this._trigger( "drag", event, ui ) === false ) {
-                               this._mouseUp( {} );
+                               this._mouseUp( new $.Event( "mouseup", event ) );
                                return false;
                        }
                        this.position = ui.position;
@@ -322,7 +322,7 @@ $.widget( "ui.draggable", $.ui.mouse, {
        cancel: function() {
 
                if ( this.helper.is( ".ui-draggable-dragging" ) ) {
-                       this._mouseUp( {} );
+                       this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
                } else {
                        this._clear();
                }
index 938d0f4b73c711290a6000d1e85aa14ccbcd65fd..1d8458b27d1344baeccd5fc223a3fc46d3fea71b 100644 (file)
@@ -189,7 +189,7 @@ return $.widget( "ui.mouse", {
                }
 
                mouseHandled = false;
-               return false;
+               event.preventDefault();
        },
 
        _mouseDistanceMet: function( event ) {