Skip to content

Commit

Permalink
Add previous answers to MathQuill inputs on the next tick.
Browse files Browse the repository at this point in the history
This fixes openwebwork/mathquill#30.
Although, I am not sure what is going on here.    For some reason
delaying filling in previous answers until the "next tick" (a timeout
with 0 delay) fixes the problem.  Probably the MathQuill math field is
not fully initialized until after the mqeditor setup method completes.

I am unable to reproduce the issue using the development build of
MathQuill directly via `npm run serve`.
  • Loading branch information
drgrice1 committed Jun 25, 2024
1 parent 82e7b3e commit d43bed0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions htdocs/js/MathQuill/mqeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,11 @@
};
answerQuill.addEventListener('keydown', answerQuill.keydownHandler);

answerQuill.mathField.latex(answerQuill.latexInput.value);
answerQuill.mathField.moveToLeftEnd();
answerQuill.mathField.blur();
setTimeout(() => {
answerQuill.mathField.latex(answerQuill.latexInput.value);
answerQuill.mathField.moveToLeftEnd();
answerQuill.mathField.blur();
}, 0);
};

// Set up MathQuill inputs that are already in the page.
Expand Down

0 comments on commit d43bed0

Please sign in to comment.