Skip to content

Commit

Permalink
Merge pull request #1131 from drgrice1/another-feedback-position-update
Browse files Browse the repository at this point in the history
When typing in a MathQuill input, update positions of all feedback popovers.
  • Loading branch information
Alex-Jordan authored Dec 11, 2024
2 parents b836a07 + a705e31 commit ba2f562
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 = {
enableSpaceNavigation: true,
Expand Down Expand Up @@ -275,8 +270,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();
}
};

// Trigger a button press when the enter key is pressed in an answer box.
Expand Down

0 comments on commit ba2f562

Please sign in to comment.