From dac125943e966ac33d9565f70a97c994fa4882c6 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 12 Jul 2024 11:47:15 -0400 Subject: [PATCH] fix: call `updateMeiData` when MEI cell is empty Resolves: #117 --- src/Editor/MeiTools.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Editor/MeiTools.ts b/src/Editor/MeiTools.ts index c111018..9804310 100644 --- a/src/Editor/MeiTools.ts +++ b/src/Editor/MeiTools.ts @@ -83,15 +83,18 @@ export class MeiTools { case 'afterChange': changes?.forEach(([row, prop, oldValue, newValue]) => { - if (prop === 'mei' && oldValue !== newValue && newValue) { - // validate the new edited mei data and update the validation status - this.updateMeiData(row, newValue, undefined, undefined); - const validationPromise = this.validationTools - .meiValidator(newValue) - .then(([isValid, errorMsg]) => { - this.updateMeiData(row, undefined, isValid, errorMsg); - }); - validationPromises.push(validationPromise); + if (prop === 'mei' && oldValue !== newValue) { + if (newValue) { + // validate the new edited mei data and update the validation status + const validationPromise = this.validationTools + .meiValidator(newValue) + .then(([isValid, errorMsg]) => { + this.updateMeiData(row, newValue, isValid, errorMsg); + }); + validationPromises.push(validationPromise); + } else { + this.updateMeiData(row, newValue, undefined, undefined); + } } }); }