Skip to content

Commit 58c3d1f

Browse files
committed
When typing in a MathQuill input, update positions of all feedback popovers.
This fixes the issue reported by @somiaj in openwebwork#1110 (comment).
1 parent c46669d commit 58c3d1f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

htdocs/js/MathQuill/mqeditor.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
if (input.classList.contains('partially-correct')) answerQuill.classList.add('partially-correct');
3838

3939
// Find the feedback button for this input if there is one on the page.
40-
const feedbackBtn = Array.from(document.querySelectorAll(`button[data-answer-labels]`)).find((btn) =>
40+
answerQuill.feedbackBtn = Array.from(document.querySelectorAll(`button[data-answer-labels]`)).find((btn) =>
4141
JSON.parse(btn.dataset.answerLabels).includes(answerLabel)
4242
);
4343

@@ -269,8 +269,11 @@
269269
answerQuill.latexInput.value = '';
270270
}
271271

272-
// If the feedback popover is open, then update its position.
273-
if (feedbackBtn) bootstrap.Popover.getInstance(feedbackBtn)?.update();
272+
// If any feedback popovers are open, then update their positions.
273+
for (const quill of Object.keys(window.answerQuills)) {
274+
if (window.answerQuills[quill].feedbackBtn)
275+
bootstrap.Popover.getInstance(window.answerQuills[quill].feedbackBtn)?.update();
276+
}
274277
};
275278

276279
input.after(answerQuill);

0 commit comments

Comments
 (0)