diff --git a/app/javascript/entrypoints/embed.tsx b/app/javascript/entrypoints/embed.tsx index f8c824d287..f034988be2 100644 --- a/app/javascript/entrypoints/embed.tsx +++ b/app/javascript/entrypoints/embed.tsx @@ -62,13 +62,15 @@ window.addEventListener('message', (e) => { // We use a timeout to allow for the React page to render before calculating the height afterInitialRender(() => { - window.parent.postMessage( - { - type: 'setHeight', - id: data.id, - height: document.getElementsByTagName('html')[0]?.scrollHeight, - }, - '*', - ); + window.requestAnimationFrame(() => { + window.parent.postMessage( + { + type: 'setHeight', + id: data.id, + height: document.getElementsByTagName('html')[0]?.scrollHeight, + }, + '*', + ); + }); }); }); diff --git a/app/javascript/hooks/useRenderSignal.ts b/app/javascript/hooks/useRenderSignal.ts index 740df4a35a..a7a429d5ad 100644 --- a/app/javascript/hooks/useRenderSignal.ts +++ b/app/javascript/hooks/useRenderSignal.ts @@ -24,9 +24,7 @@ export const useRenderSignal = () => { renderSignalReceived = true; if (typeof onInitialRender !== 'undefined') { - window.requestAnimationFrame(() => { - onInitialRender(); - }); + onInitialRender(); } }; };