iframe-resizer icon indicating copy to clipboard operation
iframe-resizer copied to clipboard

Height set to 0 when quickly switching between in-page tabs

Open brno32 opened this issue 3 years ago • 2 comments

Describe the bug I'm developing an LWC on Salesforce. The component which contains this library is placed on a tab. When the user switches tabs during certain points when the child content is loading (in between the loading circle and before the content is loaded) and then switches back, the height of the <iframe> is set to 0. It stays 0 even when the child page's content renders.

Expected behavior The iframe height should be anything other than 0, but preferably the height of the content.

I'm unable to listen to events from Salesforce as they limit you in LWC. Are there any events or callbacks I could take advantage of to get the iFrameResize object to periodically check the child content? I suspect Salesforce is swallowing some events that iFrameResize would otherwise normally listen to to know when it's time to resize.

Also, why would the height ever be set to 0? The child content is never 0 as far as I know.

Desktop:

  • OS: Windows 11
  • Browser: Chrome

Additional context Note, switching tabs does not remove any of the previously rendered elements from the DOM.

brno32 avatar Jun 07 '22 22:06 brno32

What resize method are you using?

davidjbradshaw avatar Jul 08 '22 21:07 davidjbradshaw

As a workaround you could do the following when the user switches back to the tab

documentGetElementByTagName('iframe').iFrameResizer.resize()

davidjbradshaw avatar Jul 08 '22 21:07 davidjbradshaw