Skip to content

Commit

Permalink
Update positions of all feedback popovers when typing in a MathQuill …
Browse files Browse the repository at this point in the history
…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
#1110 (comment).
  • Loading branch information
drgrice1 committed Nov 25, 2024
1 parent d96332c commit f9e94d1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions htdocs/js/MathQuill/mqeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
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) =>
answerQuill.feedbackBtn = Array.from(document.querySelectorAll(`button[data-answer-labels]`)).find((btn) =>
JSON.parse(btn.dataset.answerLabels).includes(answerLabel)
);

Expand Down Expand Up @@ -269,8 +269,11 @@
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 quill of Object.keys(window.answerQuills)) {
if (window.answerQuills[quill].feedbackBtn)
bootstrap.Popover.getInstance(window.answerQuills[quill].feedbackBtn)?.update();
}
};

input.after(answerQuill);
Expand Down

0 comments on commit f9e94d1

Please sign in to comment.