Issue Overview:
I'm encountering a persistent problem with our Confluence app where the iframe height continuously expands indefinitely. This issue arises when we set the html and body elements to 100% height in our CSS, which we need to ensure the app content properly fills the screen. Instead, the iframe content initially loads at less than half the screen height and then starts expanding without limit. Looking at the developer tools (inspect), I can see that the Iframe height is increasing infinitely.
Details:
CSS Setup:
We attempted to set the height of the html and body elements to 100% to make the content fill the screen.
We also tried setting the body height to 100vh.
Both approaches resulted in the iframe height expanding infinitely
Here is the CSS used:
<span>html</span>,
<span>body</span> {
<span>font-family</span>: Arial, sans-serif;
<span>margin</span>: <span>0</span>;
<span>padding</span>: <span>0</span>;
<span>background-color</span>: <span>#f4f4f4</span>;
<span>height</span>: <span>100%</span>;
}
<span>body</span> {
<span>height</span>: <span>100vh</span>; <span>/* Tried both 100% and 100vh */</span>
}
<span>nav</span> <span>ul</span> {
<span>list-style-type</span>: none;
<span>padding</span>: <span>0</span>;
}
<span>nav</span> <span>ul</span> <span>li</span> {
<span>display</span>: inline;
<span>margin-right</span>: <span>10px</span>;
}
<span>nav</span> <span>ul</span> <span>li</span> <span>a</span> {
<span>text-decoration</span>: none;
<span>color</span>: <span>#333</span>;
}
<span>.container</span> {
<span>margin</span>: <span>20px</span>;
<span>height</span>: <span>100%</span>;
<span>width</span>: <span>100%</span>;
}2. JavaScript for Handling Iframe Resizing:
Here is the JavaScript we used:
<span>document</span>.<span>addEventListener</span>(<span>'DOMContentLoaded'</span>, <span>function</span> () {
<span>const</span> script = <span>document</span>.<span>createElement</span>(<span>'script'</span>);
script.<span>src</span> = <span>"https://connect-cdn.atl-paas.net/all.js"</span>;
script.<span>async</span> = <span>true</span>;
<span>document</span>.<span>head</span>.<span>appendChild</span>(script);
<span>function</span> <span>resizeIframe</span>() {
<span>if</span> (<span>window</span>.<span>AP</span>) {
<span>window</span>.<span>AP</span>.<span>resize</span>();
}
}
<span>resizeIframe</span>();
<span>setInterval</span>(resizeIframe, <span>500</span>); <span>// Adjust the interval as needed</span>
});
HTML Structure:
- Our HTML structure in the Handlebars template (main.hbs) is as follows:
<span><span><!DOCTYPE <span>html</span>></span>
<span><<span>html</span>></span>
<span><<span>head</span>></span>
<span><<span>title</span>></span>{{title}}<span></<span>title</span>></span>
<span><<span>link</span> <span>rel</span>=<span>"stylesheet"</span> <span>type</span>=<span>"text/css"</span> <span>href</span>=<span>"/css/styles.css"</span>></span>
<span></<span>head</span>></span>
<span><<span>body</span>></span>
<span><<span>nav</span>></span>
<span><<span>ul</span>></span>
<span><<span>li</span>></span><span><<span>a</span> <span>href</span>=<span>"/dashboard"</span>></span>Dashboard<span></<span>a</span>></span><span></<span>li</span>></span>
<span><<span>li</span>></span><span><<span>a</span> <span>href</span>=<span>"/documentation"</span>></span>Documentation<span></<span>a</span>></span><span></<span>li</span>></span>
<span></<span>ul</span>></span>
<span></<span>nav</span>></span>
<span><<span>div</span> <span>class</span>=<span>"container"</span>></span>
{{{body}}}
<span></<span>div</span>></span>
<span><<span>script</span> <span>src</span>=<span>"/js/scripts.js"</span>></span><span></<span>script</span>></span>
<span></<span>body</span>></span>
<span></<span>html</span>></span></span>
Current Behavior:
When the app loads, the iframe height starts at less than half of the screen height.
As soon as we set the html and body height to 100%, the iframe height starts expanding infinitely.
Setting specific pixel values for height prevents infinite growth but doesn't achieve the desired responsive design.
Community Insights:
Has anyone experienced similar issues with iframe height expanding indefinitely in Confluence apps?
Are there any recommended approaches or best practices for handling iframe resizing in Confluence apps?
Could there be any specific configuration or settings we might be missing that could resolve this issue?
thank you for any help.