From fc782b59a97c4d53321126878d78b6adf2001c97 Mon Sep 17 00:00:00 2001
From: Johannes Meyer <johannes.meyer@icinga.com>
Date: Fri, 28 Jun 2019 08:29:01 +0200
Subject: [PATCH] collapsible.js: Don't collapse containers which are near to
 the maximum

---
 public/js/icinga/behavior/collapsible.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/public/js/icinga/behavior/collapsible.js b/public/js/icinga/behavior/collapsible.js
index 3c4a3f945..c2509a3ba 100644
--- a/public/js/icinga/behavior/collapsible.js
+++ b/public/js/icinga/behavior/collapsible.js
@@ -101,7 +101,16 @@
         if (!! rowSelector) {
             return $(rowSelector, $collapsible).length > ($collapsible.data('visibleRows') || this.defaultVisibleRows);
         } else {
-            return $collapsible.innerHeight() > ($collapsible.data('visibleHeight') || this.defaultVisibleHeight);
+            var actualHeight = $collapsible.innerHeight(),
+                maxHeight = $collapsible.data('visibleHeight') || this.defaultVisibleHeight;
+
+            if (actualHeight <= maxHeight) {
+                return false;
+            }
+
+            // Although the height seems larger than what it should be, make sure it's not just a small fraction
+            // i.e. more than 12 pixel and at least 10% difference
+            return actualHeight - maxHeight > 12 && actualHeight / maxHeight >= 1.1;
         }
     };