Skip to content

Commit b4332c1

Browse files
authored
fix(feedback): Wait for document to be ready before doing autoinject (#12294)
The error that folks are getting is something like this: `[Error] TypeError: null is not an object (evaluating 'qo.body.appendChild')` The problem seems to be that we're trying to inject the button into the html before the `<body>` is ready. Using async `<script defer>` or `<script async>` would probably help, but none of our snippets have that, and it would also defer error observers and everything else. What we can do for users it have the feedback integration wait before inserting the button + styles! This is a great reference: https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event Fixes #12112
1 parent 396112c commit b4332c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/feedback/src/core/integration.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,11 @@ export const buildFeedbackIntegration = ({
276276
return;
277277
}
278278

279-
_createActor().appendToDom();
279+
if (DOCUMENT.readyState === 'loading') {
280+
DOCUMENT.addEventListener('DOMContentLoaded', () => _createActor().appendToDom);
281+
} else {
282+
_createActor().appendToDom();
283+
}
280284
},
281285

282286
/**

0 commit comments

Comments
 (0)