Resize embedded iframe using parent.postMessage

I have an app that includes a table. When the table is loaded or a row is clicked, I want to send the window dimensions to the parent.

I have "Enable parent window communication" enabled and I am using the following script:

console.log("Message saying where the post is coming from")

const message = {
  height: viewport.height,
  width: viewport.width
}

parent.postMessage(message)

I have placed this in:

  • Row actions on the table using "Run script"
  • Interactions event handlers on the table using "Select row"
  • Interactions event handlers on the table using "Focus"

I never see the posted message on the parent, and I don't see the log message in Retool.