Skip to content

Commit aa56355

Browse files
committed
fix(cellNav): IE was scrolling the viewPort to the end when the focuser div received focus. Solution was to move focuser element to the render Container div
1 parent efd3798 commit aa56355

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

src/features/cellnav/js/cellnav.js

+26-17
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,8 @@
726726
};
727727
}]);
728728

729-
module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', 'uiGridCellNavConstants','$log',
730-
function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, uiGridCellNavConstants, $log) {
729+
module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', '$compile',
730+
function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, $compile) {
731731
return {
732732
replace: true,
733733
priority: -99999, //this needs to run very last
@@ -746,9 +746,32 @@
746746

747747
var grid = uiGridCtrl.grid;
748748

749+
// focusser only created for body
750+
if (containerId !== 'body') {
751+
return;
752+
}
753+
749754
// Needs to run last after all renderContainers are built
750755
uiGridCellNavService.decorateRenderContainers(grid);
751756

757+
//add an element with no dimensions that can be used to set focus and capture keystrokes
758+
var focuser = $compile('<div class="ui-grid-focuser" tabindex="-1"></div>')($scope);
759+
$elm.append(focuser);
760+
761+
uiGridCtrl.focus = function () {
762+
focuser[0].focus();
763+
};
764+
765+
// Bind to keydown events in the render container
766+
focuser.on('keydown', function (evt) {
767+
evt.uiGridTargetRenderContainerId = containerId;
768+
var rowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell();
769+
var result = uiGridCtrl.cellNav.handleKeyDown(evt);
770+
if (result === null) {
771+
uiGridCtrl.grid.api.cellNav.raise.viewPortKeyDown(evt, rowCol);
772+
}
773+
});
774+
752775
}
753776
};
754777
}
@@ -781,25 +804,11 @@
781804

782805
var grid = uiGridCtrl.grid;
783806

784-
//add an element with no dimensions that can be used to set focus and capture keystrokes
785-
var focuser = $compile('<div class="ui-grid-focuser" tabindex="-1"></div>')($scope);
786-
$elm.append(focuser);
787807

788-
uiGridCtrl.focus = function () {
789-
focuser[0].focus();
790-
};
791808

792809
uiGridCtrl.focus();
793810

794-
// Bind to keydown events in the render container
795-
focuser.on('keydown', function (evt) {
796-
evt.uiGridTargetRenderContainerId = containerId;
797-
var rowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell();
798-
var result = uiGridCtrl.cellNav.handleKeyDown(evt);
799-
if (result === null) {
800-
uiGridCtrl.grid.api.cellNav.raise.viewPortKeyDown(evt, rowCol);
801-
}
802-
});
811+
803812

804813
grid.api.core.on.scrollBegin($scope, function (args) {
805814

0 commit comments

Comments
 (0)