]> source.dussan.org Git - jquery-ui.git/commitdiff
Clicking on a draggable anchor without moving it should make it the active element...
authorSteven Luscher <jquerycla@steveluscher.com>
Thu, 2 May 2013 19:07:34 +0000 (12:07 -0700)
committerMike Sherov <mike.sherov@gmail.com>
Wed, 19 Jun 2013 12:38:57 +0000 (08:38 -0400)
tests/unit/draggable/draggable_core.js
ui/jquery.ui.draggable.js

index e2dc2a481ce098fc4c06823d907c6ac6d4dec60d..232ac6c1765e3c3dc74bbe1d13a9c471ffe48b07 100644 (file)
@@ -185,4 +185,18 @@ test( "#5727: draggable from iframe" , function() {
        TestHelpers.draggable.shouldMove( draggable1 );
 });
 
+test( "#8399: A draggable should become the active element after you are finished interacting with it, but not before.", function() {
+       expect( 2 );
+
+       var element = $( "<a href='#'>link</a>" ).appendTo( "#qunit-fixture" ).draggable();
+
+       $( document ).one( "mousemove", function() {
+               notStrictEqual( document.activeElement, element.get( 0 ), "moving a draggable anchor did not make it the active element" );
+       });
+
+       TestHelpers.draggable.move( element, 50, 50 );
+
+       strictEqual( document.activeElement, element.get( 0 ), "finishing moving a draggable anchor made it the active element" );
+});
+
 })( jQuery );
index bf90d349b0fcc20d06125e2e2158bc625d894f6e..9ee858725a779f46332ed63db214dcaef950c462 100644 (file)
@@ -263,6 +263,9 @@ $.widget("ui.draggable", $.ui.mouse, {
                        $.ui.ddmanager.dragStop(this, event);
                }
 
+               // The interaction is over; whether or not the click resulted in a drag, focus the element
+               this.element.focus();
+
                return $.ui.mouse.prototype._mouseUp.call(this, event);
        },