|
534 | 534 |
|
535 | 535 | cellNavNavigateDereg = uiGridCtrl.grid.api.cellNav.on.navigate($scope, function (newRowCol, oldRowCol, evt) {
|
536 | 536 | if ($scope.col.colDef.enableCellEditOnFocus) {
|
| 537 | + // Don't begin edit if the cell hasn't changed |
537 | 538 | if (newRowCol.row === $scope.row && newRowCol.col === $scope.col && evt && (evt.type === 'click' || evt.type === 'keydown')) {
|
538 |
| - $scope.$applyAsync(function () { |
| 539 | + $timeout(function() { |
539 | 540 | beginEdit(evt);
|
540 | 541 | });
|
541 | 542 | }
|
|
834 | 835 | });
|
835 | 836 |
|
836 | 837 | $scope.$broadcast(uiGridEditConstants.events.BEGIN_CELL_EDIT, triggerEvent);
|
837 |
| - $scope.$applyAsync(function () { |
838 |
| - // execute in a apply async to give any complex editor templates a cycle to completely render |
| 838 | + $timeout(function () { |
| 839 | + // execute in a timeout to give any complex editor templates a cycle to completely render |
839 | 840 | $scope.grid.api.edit.raise.beginCellEdit($scope.row.entity, $scope.col.colDef, triggerEvent);
|
840 | 841 | });
|
841 | 842 | }
|
|
935 | 936 |
|
936 | 937 | //set focus at start of edit
|
937 | 938 | $scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function (evt,triggerEvent) {
|
938 |
| - $scope.$applyAsync(function () { |
| 939 | + // must be in a timeout since it requires a new digest cycle |
| 940 | + $timeout(function () { |
939 | 941 | $elm[0].focus();
|
940 | 942 | //only select text if it is not being replaced below in the cellNav viewPortKeyPress
|
941 | 943 | if ($elm[0].select && ($scope.col.colDef.enableCellEditOnFocus || !(uiGridCtrl && uiGridCtrl.grid.api.cellNav))) {
|
|
1136 | 1138 | *
|
1137 | 1139 | */
|
1138 | 1140 | module.directive('uiGridEditDropdown',
|
1139 |
| - ['uiGridConstants', 'uiGridEditConstants', |
1140 |
| - function (uiGridConstants, uiGridEditConstants) { |
| 1141 | + ['uiGridConstants', 'uiGridEditConstants', '$timeout', |
| 1142 | + function (uiGridConstants, uiGridEditConstants, $timeout) { |
1141 | 1143 | return {
|
1142 | 1144 | require: ['?^uiGrid', '?^uiGridRenderContainer'],
|
1143 | 1145 | scope: true,
|
|
1152 | 1154 |
|
1153 | 1155 | //set focus at start of edit
|
1154 | 1156 | $scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
|
1155 |
| - $scope.$applyAsync(function(){ |
| 1157 | + $timeout(function(){ |
1156 | 1158 | $elm[0].focus();
|
1157 | 1159 | });
|
1158 | 1160 |
|
|
1234 | 1236 |
|
1235 | 1237 | },
|
1236 | 1238 | post: function ($scope, $elm, $attrs, controllers) {
|
1237 |
| - var uiGridCtrl, renderContainerCtrl; |
1238 |
| - if (controllers[0]) { uiGridCtrl = controllers[0]; } |
1239 |
| - if (controllers[1]) { renderContainerCtrl = controllers[1]; } |
1240 |
| - var grid = uiGridCtrl.grid; |
1241 |
| - |
1242 |
| - var handleFileSelect = function( event ){ |
| 1239 | + function handleFileSelect(event) { |
1243 | 1240 | var target = event.srcElement || event.target;
|
1244 | 1241 |
|
1245 | 1242 | if (target && target.files && target.files.length > 0) {
|
|
1290 | 1287 | } else {
|
1291 | 1288 | $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
|
1292 | 1289 | }
|
1293 |
| - }; |
| 1290 | + } |
1294 | 1291 |
|
1295 | 1292 | $elm[0].addEventListener('change', handleFileSelect, false);
|
1296 | 1293 |
|
|
0 commit comments