summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-06-16 12:01:30 +0200
committerThomas Bruederli <thomas@roundcube.net>2014-06-16 12:01:30 +0200
commit74052d49b9b8b12897a72c87445e5e6064c5001e (patch)
tree84a32f0d60a5d214cd2e874023964c72b7e4540f /program
parent7e309b872f9a60ecb5ac975fdd2f4f89b508aba8 (diff)
Avoid scrolling when moving focus from a treelist widget (#1489929)
Diffstat (limited to 'program')
-rw-r--r--program/js/treelist.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/program/js/treelist.js b/program/js/treelist.js
index cce4d17fd..ea1729806 100644
--- a/program/js/treelist.js
+++ b/program/js/treelist.js
@@ -755,7 +755,7 @@ function rcube_treelist_widget(node, p)
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 @@ function rcube_treelist_widget(node, p)
}
}
+ /**
+ * 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