From 11ac985e57a4481191e4dc44ee1fe6e913d773e8 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 24 Feb 2024 15:36:43 +0100 Subject: [PATCH] Added a workaround for sporadically (not fully reproducible) empty modal iframes in Chrome based Browsers (references #2480 and #2421) --- public/js/grocy.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/public/js/grocy.js b/public/js/grocy.js index c9cba036..cf8fa925 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -554,9 +554,27 @@ ResizeResponsiveEmbeds = function(fillEntireViewport = false) } $("embed.embed-responsive").attr("height", maxHeight.toString() + "px"); + ResizeIframes(); +} +ResizeIframes = function() +{ $("iframe.embed-responsive").each(function() { - $(this).attr("height", $(this)[0].contentWindow.document.body.scrollHeight.toString() + "px"); + var desiredHeight = $(this)[0].contentWindow.document.body.scrollHeight; + if (desiredHeight == 0) + { + // The corresponding frame should be loaded after the "onload" event fired, + // this seems to be sometimes (not really reproducible) not the case in Chrome based Browsers... + // => So if that happens, just try this again later + setTimeout(function() + { + ResizeIframes(); + }, 200); + } + else + { + $(this).attr("height", desiredHeight.toString() + "px"); + } }); } $(window).on('resize', function()