Skip to content

Commit

Permalink
Clicking on a draggable anchor without moving it should make it the a…
Browse files Browse the repository at this point in the history
…ctive element (Fixes #8399).
  • Loading branch information
Steven Luscher authored and mikesherov committed Jun 19, 2013
1 parent 91b7b9f commit bca3e05
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/unit/draggable/draggable_core.js
Expand Up @@ -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 );
3 changes: 3 additions & 0 deletions ui/jquery.ui.draggable.js
Expand Up @@ -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);
},

Expand Down

0 comments on commit bca3e05

Please sign in to comment.