Skip to content

Commit 97b44f8

Browse files
committed
Wait for the MathJax.startup.promise to update the feedback popoer.
The `inserted.bs.popover` event still does not occur late enough for the MathJax `typesetPromise` to be defined on the page sometimes. I am not seeing this once the update is deferred a bit more with a `setTimeout` call. So wait on the `MathJax.startup.promise` to be fulfilled before updating. One way to see the issue is to set the "Assist with the student answer entry process" option to "MathView". Then click the "Show Correct Answers" button in a problem with multiple answers (it can occur with one answer, but more reliably occurs with multiple answers). The popovers are not positioned correctly. Another way to see the issue is to add `console.log(MathJax.typesetPromise)` on the line before the change in this pull request (even with MathQuill enabled). You will see that most of the time, that is undefined.
1 parent 9f3f534 commit 97b44f8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

htdocs/js/Feedback/feedback.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313

1414
feedbackBtn.addEventListener('inserted.bs.popover', () => {
1515
// Render MathJax previews.
16-
if (window.MathJax) MathJax.typesetPromise?.([feedbackPopover.tip]).then(() => feedbackPopover.update());
16+
if (window.MathJax)
17+
MathJax.startup.promise
18+
.then(() => MathJax.typesetPromise([feedbackPopover.tip]))
19+
.then(() => feedbackPopover.update());
1720

1821
// Execute javascript in the answer preview.
1922
feedbackPopover.tip?.querySelectorAll('script').forEach((origScript) => {

0 commit comments

Comments
 (0)