summaryrefslogtreecommitdiffstats
path: root/slick.grid.js
diff options
context:
space:
mode:
authorMichael Leibman <michael.leibman@gmail.com>2012-11-29 15:05:45 -0800
committerMichael Leibman <michael.leibman@gmail.com>2012-11-29 15:05:45 -0800
commit86ce1e1c9d42ba5e10f8f335876e9a8ad03a5f2c (patch)
treef935afb3a1ac1f179805973cc3b309a127068be1 /slick.grid.js
parentc804311bde50db690529c8b4d5e33aaac74cb26b (diff)
downloadSlickGrid-86ce1e1c9d42ba5e10f8f335876e9a8ad03a5f2c.zip
SlickGrid-86ce1e1c9d42ba5e10f8f335876e9a8ad03a5f2c.tar.gz
SlickGrid-86ce1e1c9d42ba5e10f8f335876e9a8ad03a5f2c.tar.bz2
Fix keyboard focus getting trapped when cell has tabbable elements.
Added another focus sink just after the grid content and set focus depending on the direction of keyboard navigation.
Diffstat (limited to 'slick.grid.js')
-rw-r--r--slick.grid.js23
1 files changed, 20 insertions, 3 deletions
diff --git a/slick.grid.js b/slick.grid.js
index 3f41c34..a49e5e4 100644
--- a/slick.grid.js
+++ b/slick.grid.js
@@ -114,7 +114,7 @@ if (typeof Slick === "undefined") {
var $container;
var uid = "slickgrid_" + Math.round(1000000 * Math.random());
var self = this;
- var $focusSink;
+ var $focusSink, $focusSink2;
var $headerScroller;
var $headers;
var $headerRow, $headerRowScroller, $headerRowSpacer;
@@ -133,6 +133,7 @@ if (typeof Slick === "undefined") {
var absoluteColumnMinWidth;
var numberOfRows = 0;
+ var tabbingDirection = 1;
var activePosX;
var activeRow, activeCell;
var activeCellNode = null;
@@ -254,6 +255,8 @@ if (typeof Slick === "undefined") {
$canvas = $("<div class='grid-canvas' />").appendTo($viewport);
+ $focusSink2 = $focusSink.clone().appendTo($container);
+
if (!options.explicitInitialization) {
finishInitialization();
}
@@ -302,7 +305,7 @@ if (typeof Slick === "undefined") {
.delegate(".slick-header-column", "mouseleave", handleHeaderMouseLeave);
$headerRowScroller
.bind("scroll", handleHeaderRowScroll);
- $focusSink
+ $focusSink.add($focusSink2)
.bind("keydown", handleKeyDown);
$canvas
.bind("keydown", handleKeyDown)
@@ -2363,7 +2366,11 @@ if (typeof Slick === "undefined") {
}
function setFocus() {
- $focusSink[0].focus();
+ if (tabbingDirection == -1) {
+ $focusSink[0].focus();
+ } else {
+ $focusSink2[0].focus();
+ }
}
function scrollCellIntoView(row, cell) {
@@ -2901,6 +2908,16 @@ if (typeof Slick === "undefined") {
}
setFocus();
+ var tabbingDirections = {
+ "up": -1,
+ "down": 1,
+ "left": -1,
+ "right": 1,
+ "prev": -1,
+ "next": 1
+ };
+ tabbingDirection = tabbingDirections[dir];
+
var stepFunctions = {
"up": gotoUp,
"down": gotoDown,