Skip to content

Commit b8ec7f2

Browse files
authored
Merge pull request #166 from Automattic/more-reliable-loading
Using setTimeout loads the iframe more reliably
2 parents 4022c30 + 85df7b0 commit b8ec7f2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

frontend/block/view.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ declare global {
99
}
1010
}
1111

12-
window.addEventListener('load', () => {
12+
window.addEventListener('DOMContentLoaded', () => {
1313
const config = window.ChatrixBlockConfig;
1414
if (!config) {
1515
throw "ChatrixBlockConfig is not defined";
@@ -25,5 +25,6 @@ window.addEventListener('load', () => {
2525
attributes: config.attributes,
2626
};
2727

28-
renderBlock(containerId, props);
28+
// See https://github.com/Automattic/chatrix/issues/161 for why we use a timeout here.
29+
setTimeout( () => renderBlock(containerId, props), 1 );
2930
});

0 commit comments

Comments
 (0)