From aa56355469e0c2fe825f6c063bb2e2f7937817c7 Mon Sep 17 00:00:00 2001 From: swalters Date: Wed, 6 May 2015 11:33:53 -0500 Subject: [PATCH] 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 --- src/features/cellnav/js/cellnav.js | 43 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/features/cellnav/js/cellnav.js b/src/features/cellnav/js/cellnav.js index b0b7b256b4..36066e18de 100644 --- a/src/features/cellnav/js/cellnav.js +++ b/src/features/cellnav/js/cellnav.js @@ -726,8 +726,8 @@ }; }]); - module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', 'uiGridCellNavConstants','$log', - function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, uiGridCellNavConstants, $log) { + module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', '$compile', + function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, $compile) { return { replace: true, priority: -99999, //this needs to run very last @@ -746,9 +746,32 @@ var grid = uiGridCtrl.grid; + // focusser only created for body + if (containerId !== 'body') { + return; + } + // Needs to run last after all renderContainers are built uiGridCellNavService.decorateRenderContainers(grid); + //add an element with no dimensions that can be used to set focus and capture keystrokes + var focuser = $compile('
')($scope); + $elm.append(focuser); + + uiGridCtrl.focus = function () { + focuser[0].focus(); + }; + + // Bind to keydown events in the render container + focuser.on('keydown', function (evt) { + evt.uiGridTargetRenderContainerId = containerId; + var rowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell(); + var result = uiGridCtrl.cellNav.handleKeyDown(evt); + if (result === null) { + uiGridCtrl.grid.api.cellNav.raise.viewPortKeyDown(evt, rowCol); + } + }); + } }; } @@ -781,25 +804,11 @@ var grid = uiGridCtrl.grid; - //add an element with no dimensions that can be used to set focus and capture keystrokes - var focuser = $compile('
')($scope); - $elm.append(focuser); - uiGridCtrl.focus = function () { - focuser[0].focus(); - }; uiGridCtrl.focus(); - // Bind to keydown events in the render container - focuser.on('keydown', function (evt) { - evt.uiGridTargetRenderContainerId = containerId; - var rowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell(); - var result = uiGridCtrl.cellNav.handleKeyDown(evt); - if (result === null) { - uiGridCtrl.grid.api.cellNav.raise.viewPortKeyDown(evt, rowCol); - } - }); + grid.api.core.on.scrollBegin($scope, function (args) {