Skip to content

Commit

Permalink
Merge pull request openwebwork#1063 from drgrice1/mathquill-feedback-…
Browse files Browse the repository at this point in the history
…position-update

Update feedback popover position when typing in a MathQuill input.
  • Loading branch information
pstaabp authored May 15, 2024
2 parents f4bb83d + 395deca commit 5b19c59
Show file tree
Hide file tree
Showing 2 changed files with 7 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
1 change: 1 addition & 0 deletions macros/PG.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@ sub ENDDOCUMENT {
);
}
)->to_string,
answer_label => $answerLabel,
bs_toggle => 'popover',
bs_trigger => 'click',
bs_placement => 'bottom',
Expand Down

0 comments on commit 5b19c59

Please sign in to comment.