Skip to content

Commit 395deca

Browse files
committed
Update feedback popover position when typing in a MathQuill input.
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.
1 parent d115315 commit 395deca

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

htdocs/js/MathQuill/mqeditor.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
if (input.classList.contains('incorrect')) answerQuill.classList.add('incorrect');
3737
if (input.classList.contains('partially-correct')) answerQuill.classList.add('partially-correct');
3838

39+
// Find the feedback button for this input if there is one on the page.
40+
const feedbackBtn = document.querySelector(`button[data-answer-label="${answerLabel}"`);
41+
3942
// Default options.
4043
const cfgOptions = {
4144
spaceBehavesLikeTab: true,
@@ -261,6 +264,9 @@
261264
answerQuill.input.value = '';
262265
answerQuill.latexInput.value = '';
263266
}
267+
268+
// If the feedback popover is open, then update its position.
269+
if (feedbackBtn) bootstrap.Popover.getInstance(feedbackBtn)?.update();
264270
};
265271

266272
input.after(answerQuill);

macros/PG.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ sub ENDDOCUMENT {
12111211
);
12121212
}
12131213
)->to_string,
1214+
answer_label => $answerLabel,
12141215
bs_toggle => 'popover',
12151216
bs_trigger => 'click',
12161217
bs_placement => 'bottom',

0 commit comments

Comments
 (0)