Skip to content

Commit

Permalink
Update feedback popover position when typing in a MathQuill input.
Browse files Browse the repository at this point in the history
When a MathQuill input is typed in the width of the input grows.  So if
a feedback popover is open, then the popover is no longer position
correctly relative to the button.  So this updates the position of the
popover so that it stays correctly positioned as the MathQuill input
grows.
  • Loading branch information
drgrice1 committed Apr 18, 2024
1 parent d115315 commit bdf9b8a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions htdocs/js/MathQuill/mqeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
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 = document.querySelector(`button[data-answer-label="${answerLabel}"`);

// Default options.
const cfgOptions = {
spaceBehavesLikeTab: true,
Expand Down Expand Up @@ -261,6 +264,9 @@
answerQuill.input.value = '';
answerQuill.latexInput.value = '';
}

// If the feedback popover is open, then update its position.
if (feedbackBtn) bootstrap.Popover.getInstance(feedbackBtn)?.update();
};

input.after(answerQuill);
Expand Down

0 comments on commit bdf9b8a

Please sign in to comment.