In Confluence, I need to use AP.sizeToParent method for getting full height for iframe, but sometimes I need to use setTimeout for using this method after my React module mounted. How can I set full height for iframe before my page load?
When I’m not using this method iframe is always has minimal height and width.
We have had this problem as well, even when we wait for both window.load and other DOM rendering to complete. Some percentage if the time the reside never occurred. Using setTimeout is the only work around I have found. Would love to learn of a better answer!
Also, as an aside, using resize as a data-options property only works if the dom actually resizes after the initial page render, probably because it’s triggered by a mutation observer, so we have had to resort to an initial manual resize call or setTimeouts in those cases as well.
I’ve been working with various teams inside Atlassian to fix this issue. This turned out to be a complex issue to fix and required numerous updates to roll out to production. I believe we are just waiting on a few more updates to land in production before we can validate this as fixed.
I think the OP is referring to the need to sometimes call setTimeout sometime after initial window load to get AP.sizeToParent() to have any effect at all. I think that’s a different issue than them having the wrong height after invoking it. It’s as if there’s a race condition on the parent page side in responding to the resize vent coming across the xdm bridge.
Possibly related, I have noticed that using data-options="resize: true"only works if the DOM is mutated after initial window load. If you don’t mutate the DOM after load with JS that doesn’t trigger and you have to all AP.resize() yourself.