Skip to content

Commit

Permalink
Fixed cell navigation
Browse files Browse the repository at this point in the history
Cell navigation broke due to there being an extra element in the cell.
Also changed the color of the focused cell to be different than selected
rows to be easier to identify. Fixed issue #510. Now when mouse clicking
within cell, rows won't keep being selected and deselected.
  • Loading branch information
jonricaurte committed Jun 26, 2013
1 parent ccbdbfb commit cdf91b1
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 16 deletions.
12 changes: 10 additions & 2 deletions build/ng-grid.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 06/25/2013 22:47
* Compiled At: 06/26/2013 08:00
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -919,7 +919,7 @@ ngDomAccessProvider.prototype.focusCellElement = function ($scope, index) {
i = 1; //don't want to focus on checkbox
}
if (columns[i]) {
columns[i].children[0].focus();
columns[i].children[1].children[0].focus();
}
this.previousColumn = columnIndex;
}
Expand Down Expand Up @@ -3215,6 +3215,14 @@ ngGridDirectives.directive('ngInput', [function() {

return true;
});

elm.bind('click', function(evt) {
evt.stopPropagation();
});

elm.bind('mousedown', function(evt) {
evt.stopPropagation();
});
}
};
}]);
Expand Down
11 changes: 9 additions & 2 deletions build/ng-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 06/25/2013 22:47
* Compiled At: 06/26/2013 08:00
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -862,7 +862,7 @@ ngDomAccessProvider.prototype.focusCellElement = function ($scope, index) {
i = 1;
}
if (columns[i]) {
columns[i].children[0].focus();
columns[i].children[1].children[0].focus();
}
this.previousColumn = columnIndex;
}
Expand Down Expand Up @@ -2860,6 +2860,13 @@ ngGridDirectives.directive('ngInput', [function() {

return true;
});

elm.bind('click', function(evt) {
evt.stopPropagation();
});
elm.bind('mousedown', function(evt) {
evt.stopPropagation();
});
}
};
}]);
Expand Down
4 changes: 2 additions & 2 deletions build/ng-grid.min.js

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions ng-grid-2.0.7.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 06/25/2013 22:47
* Compiled At: 06/26/2013 08:00
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -919,7 +919,7 @@ ngDomAccessProvider.prototype.focusCellElement = function ($scope, index) {
i = 1; //don't want to focus on checkbox
}
if (columns[i]) {
columns[i].children[0].focus();
columns[i].children[1].children[0].focus();
}
this.previousColumn = columnIndex;
}
Expand Down Expand Up @@ -3215,6 +3215,14 @@ ngGridDirectives.directive('ngInput', [function() {

return true;
});

elm.bind('click', function(evt) {
evt.stopPropagation();
});

elm.bind('mousedown', function(evt) {
evt.stopPropagation();
});
}
};
}]);
Expand Down
4 changes: 2 additions & 2 deletions ng-grid-2.0.7.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ng-grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
}
.ngCellElement:focus {
outline: 0;
background-color: #c9dde1;
background-color: #b3c4c7;
}
.ngRow.canSelect {
cursor: pointer;
Expand Down
2 changes: 1 addition & 1 deletion ng-grid.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/classes/domAccessProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ngDomAccessProvider.prototype.focusCellElement = function ($scope, index) {
i = 1; //don't want to focus on checkbox
}
if (columns[i]) {
columns[i].children[0].focus();
columns[i].children[1].children[0].focus();
}
this.previousColumn = columnIndex;
}
Expand Down
8 changes: 8 additions & 0 deletions src/directives/ng-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ ngGridDirectives.directive('ngInput', [function() {

return true;
});

elm.bind('click', function(evt) {
evt.stopPropagation();
});

elm.bind('mousedown', function(evt) {
evt.stopPropagation();
});
}
};
}]);
5 changes: 4 additions & 1 deletion src/less/colors.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
// Used for column menu background
@darkGrayGreen: darken(@grayGreen, 10%);

// Used for selections
// Used for row selections
@grayBlue: #C9DDE1; // #b3c4c7;

// Used for cell selections
@darkGrayBlue: #b3c4c7;

// Color for buttons
@buttonColor: lighten(#333, 10%);
2 changes: 1 addition & 1 deletion src/less/selection.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

.ngCellElement:focus {
outline: 0;
background-color: @grayBlue;
background-color: @darkGrayBlue;
}

.ngRow.canSelect {
Expand Down
3 changes: 2 additions & 1 deletion workbench/main2.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function userController($scope, $timeout) {
multiSelect: true,
enableRowReordering: false,
enableCellSelection: true,
enableCellEdit: true,
showGroupPanel: true,
columnDefs: 'myDefs'
};
Expand All @@ -36,7 +37,7 @@ function userController($scope, $timeout) {

$scope.changeDefs = function(){
$scope.myDefs = [{ field: 'Sku', displayName: 'My Sku' },
{ field: 'Vendor', displayName: 'Supplier' },
{ field: 'Vendor', displayName: 'Supplier', editableCellTemplate: '<input type="number" style="width:100px; height:30px;" ng-model="COL_FIELD" ng-input="COL_FIELD" />' },
{ field: 'SeasonCode.test', displayName: 'My SeasonCode', cellTemplate: '<input style="width:100%;height:100%;" class="ui-widget input" type="text" ng-readonly="!row.selected" ng-model="COL_FIELD"/>' },
{ field: 'Mfg_Id', displayName: 'Manufacturer ID' },
{ field: 'UPC', displayName: 'Bar Code' }];
Expand Down

1 comment on commit cdf91b1

@swalters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

columns[i].children[1] is undefined when I edit a cell and tab to the next cell. More testing and I can see that cell navigation doesn't work at all with this commit.

Please sign in to comment.