Permalink
Browse files

Fix problem with focus in DataTable's row when user use keyboards nav…

…igation.
  • Loading branch information...
1 parent 822e9bc commit 7081ea0294f624e603610baa36cf64d6a7d92e8b SergeyPensov committed Feb 16, 2014
Showing with 39 additions and 7 deletions.
  1. +39 −7 openFaces/source/META-INF/resources/openfaces/table/table.js
@@ -857,7 +857,13 @@ O$.Table = {
passEvent = false;
this.__setSelectedRowIndexes([newIdx]);
///////////////////////////////////////////////////
- if (O$._activeElement.nodeName == "INPUT") {
+ var activeElement = null
+ if (O$._activeElement != null) {
+ activeElement = O$._activeElement
+ } else if (document.activeElement != null) {
+ activeElement = document.activeElement;
+ }
+ if (activeElement.nodeName == "INPUT") {
var needElement = O$._activeElement;
var isNeedNode = true;
var needColumn = null;
@@ -878,8 +884,6 @@ O$.Table = {
}
}
}
-
-
}
///////////////////////////////////////////////////////
O$.Table._scrollToRowIndexes(this, [newIdx]);
@@ -915,7 +919,13 @@ O$.Table = {
passEvent = false;
this.__setSelectedRowIndex(newIdx);
///////////////////////////////////////////////////
- if (O$._activeElement.nodeName == "INPUT") {
+ var activeElement = null
+ if (O$._activeElement != null) {
+ activeElement = O$._activeElement
+ } else if (document.activeElement != null) {
+ activeElement = document.activeElement;
+ }
+ if (activeElement.nodeName == "INPUT") {
var needElement = O$._activeElement;
var isNeedNode = true;
var needColumn = null;
@@ -936,8 +946,6 @@ O$.Table = {
}
}
}
-
-
}
///////////////////////////////////////////////////////
O$.Table._scrollToRowIndexes(this, [newIdx]);
@@ -1145,6 +1153,7 @@ O$.Table = {
}
}
;
+
O$.addUnloadHandler(table, function () {
table[eventName] = null;
});
@@ -1202,6 +1211,29 @@ O$.Table = {
}), true, false);
},
+ _setActiveInput:function (newIdx) {
+ var needElement = O$._activeElement;
+ var isNeedNode = true;
+ var needColumn = null;
+ var needChildrenNodes = null;
+ while (isNeedNode) {
+ needElement = needElement.parentNode;
+ if (needElement.nodeName == "TD") {
+ if (needElement._column._table == this) {
+ needColumn = needElement.cellIndex;
+ needElement = needElement.parentNode.parentNode;
+ needChildrenNodes = needElement.childNodes;
+ needElement = needChildrenNodes[newIdx];
+ needChildrenNodes = needElement.childNodes
+ needElement = needChildrenNodes[needColumn];
+ needElement = O$.getFirstFocusableControl(needElement);
+ needElement.focus();
+ isNeedNode = false;
+ }
+ }
+ }
+ },
+
_scrollToCells:function (table, cells) {
var bodyRows = table.body._getRows();
var columns = table._columns;
@@ -3677,7 +3709,7 @@ O$.Table = {
}
- columnIds.splice(oldIndex < newIndex ? oldIndex : oldIndex+gropingColumnIds.length , gropingColumnIds.length);
+ columnIds.splice(oldIndex < newIndex ? oldIndex : oldIndex + gropingColumnIds.length, gropingColumnIds.length);
}
else {
columnIds.splice(newIndex, 0, sourceColumnId);

0 comments on commit 7081ea0

Please sign in to comment.