File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 1081
1081
} ) ;
1082
1082
1083
1083
// This event is fired for all cells. If the cell matches, then focus is set
1084
- $scope . $on ( uiGridCellNavConstants . CELL_NAV_EVENT , function ( evt , rowCol , modifierDown ) {
1085
- var isFocused = grid . cellNav . focusedCells . some ( function ( focusedRowCol , index ) {
1084
+ $scope . $on ( uiGridCellNavConstants . CELL_NAV_EVENT , refreshCellFocus ) ;
1085
+
1086
+ // Refresh cell focus when a new row id added to the grid
1087
+ var dataChangeDereg = uiGridCtrl . grid . registerDataChangeCallback ( function ( grid ) {
1088
+ $timeout ( refreshCellFocus ) ;
1089
+ } , [ uiGridConstants . dataChange . ROW ] ) ;
1090
+
1091
+ function refreshCellFocus ( ) {
1092
+ var isFocused = grid . cellNav . focusedCells . some ( function ( focusedRowCol , index ) {
1086
1093
return ( focusedRowCol . row === $scope . row && focusedRowCol . col === $scope . col ) ;
1087
1094
} ) ;
1088
- if ( isFocused ) {
1095
+ if ( isFocused ) {
1089
1096
setFocused ( ) ;
1090
1097
} else {
1091
1098
clearFocus ( ) ;
1092
1099
}
1093
- } ) ;
1100
+ }
1094
1101
1095
1102
function setFocused ( ) {
1096
1103
if ( ! $scope . focused ) {
1113
1120
}
1114
1121
1115
1122
$scope . $on ( '$destroy' , function ( ) {
1123
+ dataChangeDereg ( ) ;
1124
+
1116
1125
//.off withouth paramaters removes all handlers
1117
1126
$elm . find ( 'div' ) . off ( ) ;
1118
1127
$elm . off ( ) ;
You can’t perform that action at this time.
0 commit comments