From a705e31f77369397ea1df265a218b6ed852f77da Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 1 Oct 2024 16:14:37 -0500 Subject: [PATCH] Update positions of all feedback popovers when typing in a MathQuill input, Don't only update the popover corresponding to the input that is currently being typed in. This fixes the issue reported by @somiaj in https://github.com/openwebwork/pg/pull/1110#issuecomment-2380357222. --- htdocs/js/MathQuill/mqeditor.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/js/MathQuill/mqeditor.js b/htdocs/js/MathQuill/mqeditor.js index c2f589a3d..60dd2520f 100644 --- a/htdocs/js/MathQuill/mqeditor.js +++ b/htdocs/js/MathQuill/mqeditor.js @@ -36,11 +36,6 @@ if (input.classList.contains('incorrect')) answerQuill.classList.add('incorrect'); if (input.classList.contains('partially-correct')) answerQuill.classList.add('partially-correct'); - // Find the feedback button for this input if there is one on the page. - const feedbackBtn = Array.from(document.querySelectorAll(`button[data-answer-labels]`)).find((btn) => - JSON.parse(btn.dataset.answerLabels).includes(answerLabel) - ); - // Default options. const cfgOptions = { spaceBehavesLikeTab: true, @@ -269,8 +264,10 @@ answerQuill.latexInput.value = ''; } - // If the feedback popover is open, then update its position. - if (feedbackBtn) bootstrap.Popover.getInstance(feedbackBtn)?.update(); + // If any feedback popovers are open, then update their positions. + for (const popover of document.querySelectorAll('.ww-feedback-btn')) { + bootstrap.Popover.getInstance(popover)?.update(); + } }; input.after(answerQuill);