From eb82b35df9807d0e002b9fd676692d51d007b319 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Mon, 16 Jun 2014 06:41:09 -0400 Subject: [PATCH] Merge branch 'master' of github.com:roundcube/roundcubemail --- program/js/treelist.js | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/program/js/treelist.js b/program/js/treelist.js index cce4d17..1427c24 100644 --- a/program/js/treelist.js +++ b/program/js/treelist.js @@ -739,7 +739,7 @@ if (li.length) { focus_next(li, (mod = keyCode == 38 || keyCode == 63232 ? -1 : 1)); } - break; + return rcube_event.cancel(e); case 37: // Left arrow key case 39: // Right arrow key @@ -755,7 +755,7 @@ case 9: // Tab // jump to last/first item to move focus away from the treelist widget by tab var limit = rcube_event.get_modifier(e) == SHIFT_KEY ? 'first' : 'last'; - container.find('li[role=treeitem]:has(a)')[limit]().find('a:'+limit).focus(); + focus_noscroll(container.find('li[role=treeitem]:has(a)')[limit]().find('a:'+limit)); break; } @@ -788,6 +788,19 @@ } } + /** + * Focus the given element without scrolling the list container + */ + function focus_noscroll(elem) + { + if (elem.length) { + var frame = container.parent().get(0) || { scrollTop:0 }, + y = frame.scrollTop || frame.scrollY; + elem.focus(); + frame.scrollTop = y; + } + } + ///// drag & drop support -- Gitblit v1.9.1