Skip to content

Commit

Permalink
fix: use grid headerHeight instead of random 30px value for menu heig…
Browse files Browse the repository at this point in the history
…ht calculation
  • Loading branch information
Dana Greenberg committed Jul 8, 2016
1 parent 575b901 commit 5a67dd8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/js/core/directives/ui-grid-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18
$scope.dynamicStyles = '';

var setupHeightStyle = function(gridHeight) {
// magic number of 30 because the grid menu displays somewhat below
// the top of the grid. It is approximately 30px.
var gridMenuMaxHeight = gridHeight - 30;
$scope.dynamicStyles = [
//menu appears under header row, so substract that height from it's total
// additional 20px for general padding
var gridMenuMaxHeight = gridHeight - uiGridCtrl.grid.headerHeight - 20;
$scope.dynamicStyles = [
'.grid' + uiGridCtrl.grid.id + ' .ui-grid-menu-mid {',
'max-height: ' + gridMenuMaxHeight + 'px;',
'}'
Expand Down
3 changes: 2 additions & 1 deletion test/unit/core/directives/ui-grid-menu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ describe('ui-grid-menu', function() {
$scope.$broadcast('show-menu');

expect(isolateScope.dynamicStyles).toBeDefined();
expect(isolateScope.dynamicStyles).toContain('.grid1234 .ui-grid-menu-mid { max-height: 370px; }');
expect(isolateScope.dynamicStyles).toContain('.grid1234 .ui-grid-menu-mid { max-height: 350px; }');
});

function compileWithGrid () {
var grid = angular.element('<div><div id="test-grid-menu" ui-grid-menu menu-items="items"></div></div>');
grid.data('$uiGridController', $controller(function ($scope) {
this.grid = {
gridHeight: 400,
headerHeight: 30,
id: '1234',
api: {
core: {
Expand Down

0 comments on commit 5a67dd8

Please sign in to comment.