Skip to content

Commit

Permalink
fix(Grid): Add missing promise wait in refresh(). (#5934)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lobo78 authored and dlgski committed Mar 3, 2017
1 parent 2974e6d commit e23a2af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/js/core/factories/Grid.js
Expand Up @@ -2074,10 +2074,10 @@ angular.module('ui.grid')
self.setVisibleColumns(renderableColumns);
}).catch(angular.noop);

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

self.refreshCanvas(true);
return $q.all([p1, p2, p3]).then(function () {
self.redrawInPlace(rowsAltered);
}).catch(angular.noop);
};

Expand Down
6 changes: 4 additions & 2 deletions test/unit/core/directives/ui-grid-row.spec.js
@@ -1,5 +1,5 @@
describe('uiGridRow', function () {
var grid, data, columnDefs, $scope, $compile, $document, recompile, uiGridConstants, GridRow, gridUtil;
var grid, data, columnDefs, $scope, $compile, $document, recompile, uiGridConstants, GridRow, gridUtil, $timeout;

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

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

beforeEach(inject(function (_$compile_, $rootScope, _$document_, _uiGridConstants_, _GridRow_, _gridUtil_) {
beforeEach(inject(function (_$compile_, $rootScope, _$document_, _uiGridConstants_, _GridRow_, _gridUtil_, _$timeout_) {
$scope = $rootScope;
$compile = _$compile_;
$document = _$document_;
uiGridConstants = _uiGridConstants_;
GridRow = _GridRow_;
gridUtil = _gridUtil_;
$timeout = _$timeout_;

$scope.gridOpts = {
columnDefs: columnDefs,
Expand Down Expand Up @@ -87,6 +88,7 @@ describe('uiGridRow', function () {
});
});
$scope.$digest();
$timeout.flush();
});

it("should have the forth row with text", function() {
Expand Down
6 changes: 5 additions & 1 deletion test/unit/core/directives/uiGridCell.spec.js
Expand Up @@ -99,7 +99,8 @@ describe('uiGridCell', function () {
columnDefs: [{ field: 'name', width: 100 }, { field: 'age', width: 50 }],
data: [
{ name: 'Bob', age: 50 }
]
],
onRegisterApi: function( gridApi ){ $scope.gridApi = gridApi; }
};

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

$scope.gridApi.grid.refresh();
$scope.$digest();

// The first column should now be 50px wide
expect(firstColAgain.outerWidth()).toEqual(50, 'first cell again is 50px, counting border');
expect(firstHeaderCellAgain.outerWidth()).toEqual(50, 'header cell again is 50px, counting border');
Expand Down

0 comments on commit e23a2af

Please sign in to comment.