Skip to content

Commit 5a67dd8

Browse files
author
Dana Greenberg
committed
fix: use grid headerHeight instead of random 30px value for menu height calculation
1 parent 575b901 commit 5a67dd8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Diff for: src/js/core/directives/ui-grid-menu.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18
4747
$scope.dynamicStyles = '';
4848

4949
var setupHeightStyle = function(gridHeight) {
50-
// magic number of 30 because the grid menu displays somewhat below
51-
// the top of the grid. It is approximately 30px.
52-
var gridMenuMaxHeight = gridHeight - 30;
53-
$scope.dynamicStyles = [
50+
//menu appears under header row, so substract that height from it's total
51+
// additional 20px for general padding
52+
var gridMenuMaxHeight = gridHeight - uiGridCtrl.grid.headerHeight - 20;
53+
$scope.dynamicStyles = [
5454
'.grid' + uiGridCtrl.grid.id + ' .ui-grid-menu-mid {',
5555
'max-height: ' + gridMenuMaxHeight + 'px;',
5656
'}'

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ describe('ui-grid-menu', function() {
8080
$scope.$broadcast('show-menu');
8181

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

8686
function compileWithGrid () {
8787
var grid = angular.element('<div><div id="test-grid-menu" ui-grid-menu menu-items="items"></div></div>');
8888
grid.data('$uiGridController', $controller(function ($scope) {
8989
this.grid = {
9090
gridHeight: 400,
91+
headerHeight: 30,
9192
id: '1234',
9293
api: {
9394
core: {

0 commit comments

Comments
 (0)