Skip to content

Commit bca3e05

Browse files
Steven Luschermikesherov
authored andcommitted
Clicking on a draggable anchor without moving it should make it the active element (Fixes #8399).
1 parent 91b7b9f commit bca3e05

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/unit/draggable/draggable_core.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,18 @@ test( "#5727: draggable from iframe" , function() {
185185
TestHelpers.draggable.shouldMove( draggable1 );
186186
});
187187

188+
test( "#8399: A draggable should become the active element after you are finished interacting with it, but not before.", function() {
189+
expect( 2 );
190+
191+
var element = $( "<a href='#'>link</a>" ).appendTo( "#qunit-fixture" ).draggable();
192+
193+
$( document ).one( "mousemove", function() {
194+
notStrictEqual( document.activeElement, element.get( 0 ), "moving a draggable anchor did not make it the active element" );
195+
});
196+
197+
TestHelpers.draggable.move( element, 50, 50 );
198+
199+
strictEqual( document.activeElement, element.get( 0 ), "finishing moving a draggable anchor made it the active element" );
200+
});
201+
188202
})( jQuery );

ui/jquery.ui.draggable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ $.widget("ui.draggable", $.ui.mouse, {
263263
$.ui.ddmanager.dragStop(this, event);
264264
}
265265

266+
// The interaction is over; whether or not the click resulted in a drag, focus the element
267+
this.element.focus();
268+
266269
return $.ui.mouse.prototype._mouseUp.call(this, event);
267270
},
268271

0 commit comments

Comments
 (0)