# Macro with body does not properly resize child macros

**URL:** <https://community.developer.atlassian.com/t/macro-with-body-does-not-properly-resize-child-macros/44178>\
**Category:** Confluence Cloud\
**Created:** [January 2, 2021, 1:31pm UTC](https://community.developer.atlassian.com/t/macro-with-body-does-not-properly-resize-child-macros/44178 "2021-01-02T13:31:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PhilipFeldmann](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@PhilipFeldmann](https://community.developer.atlassian.com/u/PhilipFeldmann)\
**Post date:** [January 2, 2021, 1:31pm UTC](https://community.developer.atlassian.com/t/macro-with-body-does-not-properly-resize-child-macros/44178/1 "2021-01-02T13:31:30Z")

</div>

I’ve got a macro with a body that should be able to hold other macros with no body. When rendering the macro I am receiving its content in storage format from `rest/api/content/{pageId}/history/{pageVersion}/macro/id/{macroId}` and then converting it to HTML using `rest/api/contentbody/convert/view`.

With normal elements this works fine, but when there are other macros inside, they all get an iframe of 300x150px and it does not resize afterwards. It does not work with other third party macros either.

 ![38](https://global.discourse-cdn.com/atlassiandeveloper/original/3X/0/b/0b6fa2b997a0af50be92a5cad52615bc20730ee5.png)  
How can I get the macro iframes inside to resize properly?

---

<div class="post-metadata">

**Author:** ![PhilipFeldmann](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@PhilipFeldmann](https://community.developer.atlassian.com/u/PhilipFeldmann)\
**Post date:** [January 9, 2021, 11:25am UTC](https://community.developer.atlassian.com/t/macro-with-body-does-not-properly-resize-child-macros/44178/2 "2021-01-09T11:25:52Z")

</div>

Also here is a minimal example that can reproduce the issue: [GitHub - philipfeldmann/ace-macro-bug-reproducible: A minimal example of macro bodies not rendering correctly, forked form https://bitbucket.org/atlassian/confluence-helloworld-addon.git.](https://github.com/philipfeldmann/ace-macro-bug-reproducible)

---

<div class="post-metadata">

**Author:** ![anon21029823](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@anon21029823](https://community.developer.atlassian.com/u/anon21029823)\
**Post date:** [January 13, 2021, 5:28pm UTC](https://community.developer.atlassian.com/t/macro-with-body-does-not-properly-resize-child-macros/44178/3 "2021-01-13T17:28:21Z")

</div>

Hi @PhilipFeldmann,

I think the key thing to note here is probably that no matter the HTML you’re rendering in **your DOM** , you are responsible for sizing it correctly. An `iframe` is no different from a `div` or really anything else in this case.

You will need to add some JavaScript or CSS yourself to your wrapper macro that resizes the nested macro how you want it. Does that make sense?

Cheers,  
Sven

---

<div class="post-metadata">

**Author:** ![PhilipFeldmann](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@PhilipFeldmann](https://community.developer.atlassian.com/u/PhilipFeldmann)\
**Post date:** [January 13, 2021, 6:55pm UTC](https://community.developer.atlassian.com/t/macro-with-body-does-not-properly-resize-child-macros/44178/4 "2021-01-13T18:55:43Z")

</div>

Thanks @anon21029823 .  
How is this supposed to work? Confluence has more information about how to size frames correctly, than a plugin has, as it depends on the (inner) macro itself. Some macros will have a fixed amount of px as width, others will just want to get 100% of the container. That works when macros are not wrapped inside each other, but confluence does the work here, as every macro talks to confluence over the iframe bridge and can therefore be sized according to the content.

For my plugin that macro iframe is just a black box, I can’t look what’s inside it due to the shadow dom. And just measuring the dimensions of the frame does not work, because it’ll always be sized to 300x150px.

---

<div class="post-metadata">

**Author:** ![anon21029823](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@anon21029823](https://community.developer.atlassian.com/u/anon21029823)\
**Post date:** [January 13, 2021, 8:09pm UTC](https://community.developer.atlassian.com/t/macro-with-body-does-not-properly-resize-child-macros/44178/5 "2021-01-13T20:09:55Z")

</div>

For the initial size you’ll of course have to trust on what Atlassian’s REST API gives you and that might or might not be what the given macro has specified in it’s descriptor.

For resizing the nested macro dynamically whenever it’s calling `AP.resize` you’ll likely need to implement this in your wrapper macro via Atlassian’s simple-xdm bridge. (See my other response [here](https://community.developer.atlassian.com/t/nested-cloud-macros-in-confluence-is-it-really-supported/44372) and especially the part about auto resizing iframes in the readme of the linked simple-xdm repo)

Note that I’m saying **likely** , because I haven’t actually tried this myself - but if you approach it from a technical side: how else is `AP.resize()` going to have any effect? It definitely needs to trigger something in the context of your wrapper macro that then adjusts the size of the iframe, and simple-xdm seems to be the way to do that.

Cheers,  
Sven

---

<div class="post-metadata">

**Author:** ![PhilipFeldmann](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@PhilipFeldmann](https://community.developer.atlassian.com/u/PhilipFeldmann)\
**Post date:** [January 14, 2021, 5:55pm UTC](https://community.developer.atlassian.com/t/macro-with-body-does-not-properly-resize-child-macros/44178/6 "2021-01-14T17:55:26Z")

</div>

Thanks a lot Sven, I’ll have a look into it and see what can be done.
