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-08 22:22:59 +08:00
committed by Jun Pataleta
parent c28639acd9
commit 426e4043a4
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
@@ -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();
}
});