MDL-79264 tiny_equation: Correct debounce method

The debounced method was being called immediately instead of being
debounced.
This commit is contained in:
Andrew Nicols 2023-09-07 22:29:44 +08:00 committed by Jun Pataleta
parent 6ceabf28d3
commit 12c67aaae1
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
3 changed files with 5 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -66,6 +66,7 @@ const displayDialogue = async(editor) => {
currentForm = root.querySelector(Selectors.elements.form);
const contextId = getContextId(editor);
const debouncedPreviewUpdater = debounce(() => updatePreview(getContextId(editor)), 500);
$root.on(ModalEvents.hidden, () => {
modalPromises.destroy();
@ -95,14 +96,14 @@ const displayDialogue = async(editor) => {
modalPromises.destroy();
}
if (textArea) {
debounce(updatePreview(contextId), 500);
debouncedPreviewUpdater();
}
});
root.addEventListener('keyup', (e) => {
const textArea = e.target.closest(Selectors.elements.equationTextArea);
if (textArea) {
debounce(updatePreview(contextId), 500);
debouncedPreviewUpdater();
}
});