From 63ca9f6f5a7149d770a79c06b1d0c01c3a641c1e Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 18 Feb 2016 11:08:13 +0100 Subject: [PATCH] fix(legend): only add overflow scroll when needed In firefox the scrollbar is always show when setting overflow: scroll. This commit makes sure the overflow setting is only applied when needed. closes #4049 --- public/app/plugins/panel/graph/legend.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/public/app/plugins/panel/graph/legend.js b/public/app/plugins/panel/graph/legend.js index a09bbbb6cb1..fb2c590034d 100644 --- a/public/app/plugins/panel/graph/legend.js +++ b/public/app/plugins/panel/graph/legend.js @@ -90,14 +90,6 @@ function (angular, _, $) { } function render() { - if (panel.legend.rightSide) { - var panelheight = scope.ctrl.height || scope.ctrl.panel.height || scope.ctrl.row.height; - $container.css("height", panelheight); - $container.toggleClass('graph-legend-fixed-height', true); - } else { - $container.css("height", ""); - } - if (firstRender) { elem.append($container); $container.on('click', '.graph-legend-icon', openColorSelector); @@ -184,6 +176,19 @@ function (angular, _, $) { html += ''; $container.append($(html)); } + + var legendContainerHeight = $container.parent().height(); + var legendHeight = $container.height(); + + if (panel.legend.rightSide && legendHeight >= legendContainerHeight) { + $container.toggleClass('graph-legend-fixed-height', true); + } + + if (panel.legend.rightSide) { + $container.css("height", scope.ctrl.height || scope.ctrl.panel.height || scope.ctrl.row.height); + } else { + $container.css("height", ""); + } } } };