From 26bce22bff45fe30e79f0f9e8ff1baf8e7589b8d Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 17 Feb 2019 09:59:27 +0100 Subject: [PATCH] Fix bug when aborting dragging with ESC key didn't stop the move action (#6623) + small code improvements + focus the list on drag start to make sure it's focused state is up-to-date which is needed for proper keypress handling (e.g. ESC key on drag action) --- CHANGELOG | 1 + program/js/app.js | 8 +++++--- program/js/list.js | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cd239c155..d22b545a6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -66,6 +66,7 @@ CHANGELOG Roundcube Webmail - Fix so ANY record is not used for email domain validation, use A, MX, CNAME, AAAA instead (#6581) - Fix so mime_content_type check in Installer uses files that should always be available (i.e. from program/resources) (#6599) - Fix missing CSRF token on a link to download too-big message part (#6621) +- Fix bug when aborting dragging with ESC key didn't stop the move action (#6623) RELEASE 1.4-beta ---------------- diff --git a/program/js/app.js b/program/js/app.js index 66eea0ef6..2b364ee27 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -1695,6 +1695,7 @@ function rcube_webmail() if (menu) { $(menu).hide(); } + this.command(action, this.env.drag_target); this.env.drag_target = null; }; @@ -1724,7 +1725,8 @@ function rcube_webmail() else if (list = this.contact_list) model = this.env.contactfolders; - if (this.drag_active && model && this.env.last_folder_target) { + // Note: we accept only mouse events to ignore dragging aborts with ESC key (#6623) + if (this.drag_active && model && this.env.last_folder_target && !rcube_event.is_keyboard(e)) { var target = model[this.env.last_folder_target]; list.draglayer.hide(); @@ -1809,7 +1811,7 @@ function rcube_webmail() // remove focus from list widgets if (window.rcube_list_widget && rcube_list_widget._instances.length) { - $.each(rcube_list_widget._instances, function(i,list){ + $.each(rcube_list_widget._instances, function(i,list) { if (list && !rcube_mouse_is_over(e, list.list.parentNode)) list.blur(); }); @@ -1824,7 +1826,7 @@ function rcube_webmail() } // reset popup menus; delayed to have updated menu_stack data - setTimeout(function(e){ + setTimeout(function(e) { var obj, skip, config, id, i, parents = $(target).parents(); for (i = ref.menu_stack.length - 1; i >= 0; i--) { id = ref.menu_stack[i]; diff --git a/program/js/list.js b/program/js/list.js index a4b800131..1e1c830ae 100644 --- a/program/js/list.js +++ b/program/js/list.js @@ -642,6 +642,7 @@ drag_row: function(e, id) rcube_event.add_listener({event:'mousemove', object:this, method:'drag_mouse_move'}); rcube_event.add_listener({event:'mouseup', object:this, method:'drag_mouse_up'}); + if (bw.touch) { rcube_event.add_listener({event:'touchmove', object:this, method:'drag_mouse_move'}); rcube_event.add_listener({event:'touchend', object:this, method:'drag_mouse_up'}); @@ -649,6 +650,7 @@ drag_row: function(e, id) // enable dragging over iframes this.add_dragfix(); + this.focus(); } return false; @@ -1419,9 +1421,7 @@ highlight_children: function(id, status) */ key_press: function(e) { - var target = e.target || {}; - - if (!this.focused || target.nodeName == 'INPUT' || target.nodeName == 'TEXTAREA' || target.nodeName == 'SELECT') + if (!this.focused || $(e.target).is('input,textarea,select')) return true; var keyCode = rcube_event.get_keycode(e),