From a5be87d2343dbbebbb7697c33ca24dba00fd75f0 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 7 Feb 2014 16:06:15 +0800 Subject: [PATCH] MDL-44042 Javascript: Handle moving to the top of the current section with keyboard --- lib/yui/dragdrop/dragdrop.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/yui/dragdrop/dragdrop.js b/lib/yui/dragdrop/dragdrop.js index 773373c2fc6..3b223c6dc71 100644 --- a/lib/yui/dragdrop/dragdrop.js +++ b/lib/yui/dragdrop/dragdrop.js @@ -418,6 +418,15 @@ YUI.add('moodle-core-dragdrop', function(Y) { // Simulate the full sequence. this.drag_start(dragevent); this.global_drop_over(dropevent); + + if (droptarget.hasClass(this.parentnodeclass) && droptarget.contains(dragcontainer)) { + // The global_drop_over function does not handle the case where an item was moved up, without the + // 'goingup' variable being set, as is the case wih keyboard drag/drop. We must detect this case and + // apply it after the drop_over, but before the drop_hit event in order for it to be moved to the + // correct location. + droptarget.prepend(dragcontainer); + } + this.global_drop_hit(dropevent); M.core.dragdrop.keydraghandle.focus(); },