Skip to content

Commit

Permalink
fix: 🐛 ensure viewport height cannot be negative
Browse files Browse the repository at this point in the history
Closes: #3034
  • Loading branch information
marcelo-portugal authored and mportuga committed Aug 7, 2021
1 parent c9abb8b commit a7111a1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/cellnav/test/uiGridCellNavService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('ui.grid.edit uiGridCellNavService', function() {
$timeout.flush();

expect(args.grid).toEqual(grid);
expect(Math.round(args.y.percentage * 10) / 10).toBe(0.4);
expect(Math.round(args.y.percentage * 10) / 10).toBe(0.5);
expect(isNaN(args.x.percentage)).toEqual(true);
});

Expand Down Expand Up @@ -233,7 +233,7 @@ describe('ui.grid.edit uiGridCellNavService', function() {
});
$timeout.flush();

expect(Math.round(args.y.percentage * 10) / 10).toEqual(0.5);
expect(Math.round(args.y.percentage * 10) / 10).toEqual(0.6);
expect(args.x).toBe(null);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/factories/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ angular.module('ui.grid')

// gridUtil.logDebug('viewPortHeight', viewPortHeight);

return viewPortHeight;
return viewPortHeight > 0 ? viewPortHeight : 0;
};

Grid.prototype.getViewportWidth = function getViewportWidth() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/factories/GridRenderContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ angular.module('ui.grid')

viewPortHeight = viewPortHeight + adjustment.height;

return viewPortHeight;
return viewPortHeight > 0 ? viewPortHeight : 0;
};

GridRenderContainer.prototype.getViewportWidth = function getViewportWidth() {
Expand Down

0 comments on commit a7111a1

Please sign in to comment.