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 Dec 8, 2024
1 parent 0ca9c31 commit a705e31
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions htdocs/js/MathQuill/mqeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a705e31

Please sign in to comment.