This creates an extremely bad user experience for the case of opening forms within an iframe. Now a user needs to: 1. Open the form (iframe modal) 2. Fill out the information 3. Submit the information 4. Then go and close the iframe manually (it should just close automatically in the last step)
Some easy solutions to this could be to simply allow an iframe to be embedded within a react component (rather than as an overlay), then you are masking what is an internal/external resource - in this case you should be able to expose a panel of buttons to programatically close the iframe as you can any other overlay. This solution would allow you to collapse steps 3 and 4 above by skipping step 3 and ensuring progressive updates in the iframed forms in step 2, and just providing a single "Submit" button. Either way, even for static content, it's opening and closing can be controlled without leaving the 'hubspot' sandboxed react experience.
Another solution would be to add a listener to the iframe, and allow the child window to communicate with that listener using some predefined set of commands. This is probably more challenging, but would open up the possibilities for devs even more.
Hello! You can have the iFrame close automatically by sending a postMessage! This went undocumented for a while, apologies! Docs on this are now here under the code example. Execute the following from within the iFrame to automatically close the opened iFrame in the CRM: window.parent.postMessage(JSON.stringify({"action": "DONE"}), "*");