Skip to content

Commit e23a2af

Browse files
lobo78dlgski
lobo78
authored andcommitted
fix(Grid): Add missing promise wait in refresh(). (#5934)
Fix issue with ui-grid-auto-resize where every tick (250ms) the grid increases by 0.2 pixel. Also fixes Firefox issue where grid rows would sometimes be endlessly redrawn if ui-grid-auto-resize was used.
1 parent 2974e6d commit e23a2af

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

Diff for: src/js/core/factories/Grid.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2074,10 +2074,10 @@ angular.module('ui.grid')
20742074
self.setVisibleColumns(renderableColumns);
20752075
}).catch(angular.noop);
20762076

2077-
return $q.all([p1, p2]).then(function () {
2078-
self.redrawInPlace(rowsAltered);
2077+
var p3 = self.refreshCanvas(true);
20792078

2080-
self.refreshCanvas(true);
2079+
return $q.all([p1, p2, p3]).then(function () {
2080+
self.redrawInPlace(rowsAltered);
20812081
}).catch(angular.noop);
20822082
};
20832083

Diff for: test/unit/core/directives/ui-grid-row.spec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
describe('uiGridRow', function () {
2-
var grid, data, columnDefs, $scope, $compile, $document, recompile, uiGridConstants, GridRow, gridUtil;
2+
var grid, data, columnDefs, $scope, $compile, $document, recompile, uiGridConstants, GridRow, gridUtil, $timeout;
33

44
data = [
55
{ "name": "Bob", "age": 35 },
@@ -15,13 +15,14 @@ describe('uiGridRow', function () {
1515

1616
beforeEach(module('ui.grid'));
1717

18-
beforeEach(inject(function (_$compile_, $rootScope, _$document_, _uiGridConstants_, _GridRow_, _gridUtil_) {
18+
beforeEach(inject(function (_$compile_, $rootScope, _$document_, _uiGridConstants_, _GridRow_, _gridUtil_, _$timeout_) {
1919
$scope = $rootScope;
2020
$compile = _$compile_;
2121
$document = _$document_;
2222
uiGridConstants = _uiGridConstants_;
2323
GridRow = _GridRow_;
2424
gridUtil = _gridUtil_;
25+
$timeout = _$timeout_;
2526

2627
$scope.gridOpts = {
2728
columnDefs: columnDefs,
@@ -87,6 +88,7 @@ describe('uiGridRow', function () {
8788
});
8889
});
8990
$scope.$digest();
91+
$timeout.flush();
9092
});
9193

9294
it("should have the forth row with text", function() {

Diff for: test/unit/core/directives/uiGridCell.spec.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ describe('uiGridCell', function () {
9999
columnDefs: [{ field: 'name', width: 100 }, { field: 'age', width: 50 }],
100100
data: [
101101
{ name: 'Bob', age: 50 }
102-
]
102+
],
103+
onRegisterApi: function( gridApi ){ $scope.gridApi = gridApi; }
103104
};
104105

105106
// Create a grid elements
@@ -132,6 +133,9 @@ describe('uiGridCell', function () {
132133
// The column root classes should have changed
133134
expect(class2).not.toEqual(class1);
134135

136+
$scope.gridApi.grid.refresh();
137+
$scope.$digest();
138+
135139
// The first column should now be 50px wide
136140
expect(firstColAgain.outerWidth()).toEqual(50, 'first cell again is 50px, counting border');
137141
expect(firstHeaderCellAgain.outerWidth()).toEqual(50, 'header cell again is 50px, counting border');

0 commit comments

Comments
 (0)