File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 677
677
// Figure out which new row+combo we're navigating to
678
678
var rowCol = uiGridCtrl . grid . renderContainers [ containerId ] . cellNav . getNextRowCol ( direction , lastRowCol . row , lastRowCol . col ) ;
679
679
var focusableCols = uiGridCtrl . grid . renderContainers [ containerId ] . cellNav . getFocusableCols ( ) ;
680
-
680
+ var rowColSelectIndex = uiGridCtrl . grid . api . cellNav . rowColSelectIndex ( rowCol ) ;
681
681
// Shift+tab on top-left cell should exit cellnav on render container
682
682
if (
683
683
// Navigating left
689
689
evt . keyCode === uiGridConstants . keymap . TAB &&
690
690
evt . shiftKey
691
691
) {
692
+ grid . cellNav . focusedCells . splice ( rowColSelectIndex , 1 ) ;
692
693
uiGridCtrl . cellNav . clearFocus ( ) ;
693
694
return true ;
694
695
}
702
703
evt . keyCode === uiGridConstants . keymap . TAB &&
703
704
! evt . shiftKey
704
705
) {
706
+ grid . cellNav . focusedCells . splice ( rowColSelectIndex , 1 ) ;
705
707
uiGridCtrl . cellNav . clearFocus ( ) ;
706
708
return true ;
707
709
}
Original file line number Diff line number Diff line change @@ -53,4 +53,22 @@ describe('ui.grid.cellNav directive', function () {
53
53
$scope . grid . cellNav . broadcastCellNav ( { row : $scope . grid . rows [ 1 ] , col : $scope . grid . columns [ 0 ] } , true ) ;
54
54
expect ( $scope . gridApi . cellNav . getCurrentSelection ( ) . length ) . toEqual ( 2 ) ;
55
55
} ) ;
56
+
57
+
58
+ it ( 'handleKeyDown should clear the focused cells list when clearing focus' , function ( ) {
59
+ // first ensure that a cell is selected
60
+ $scope . grid . cellNav . broadcastCellNav ( { row : $scope . grid . rows [ 0 ] , col : $scope . grid . columns [ 0 ] } , true ) ;
61
+ var rowColToTest = { row : $scope . grid . rows [ 0 ] , col : $scope . grid . columns [ 0 ] } ;
62
+ var evt = jQuery . Event ( "keydown" ) ;
63
+ evt . keyCode = uiGridConstants . keymap . TAB ;
64
+ $scope . grid . cellNav . lastRowCol = rowColToTest ;
65
+
66
+ // simulate tabbing out of grid
67
+ elm . controller ( 'uiGrid' ) . cellNav . handleKeyDown ( evt ) ;
68
+ expect ( $scope . grid . cellNav . focusedCells . length ) . toEqual ( 0 ) ;
69
+
70
+ // simulate restoring focus
71
+ $scope . grid . cellNav . broadcastCellNav ( { row : $scope . grid . rows [ 0 ] , col : $scope . grid . columns [ 0 ] } , true ) ;
72
+ expect ( $scope . grid . cellNav . focusedCells . length ) . toEqual ( 1 ) ;
73
+ } ) ;
56
74
} ) ;
You can’t perform that action at this time.
0 commit comments