From bca3e058e89bf40806170149b8029dfe52644248 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Thu, 2 May 2013 12:07:34 -0700 Subject: [PATCH] Clicking on a draggable anchor without moving it should make it the active element (Fixes #8399). --- tests/unit/draggable/draggable_core.js | 14 ++++++++++++++ ui/jquery.ui.draggable.js | 3 +++ 2 files changed, 17 insertions(+) diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index e2dc2a481..232ac6c17 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -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 = $( "link" ).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 ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index bf90d349b..9ee858725 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -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); }, -- 2.39.5