Skip to content

Commit

Permalink
fix: remove meiData entry after clearing cell
Browse files Browse the repository at this point in the history
Refs: #122
  • Loading branch information
kunfang98927 committed Jul 12, 2024
1 parent ca06fd8 commit 3cb56a9
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/Editor/MeiTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,22 @@ export class MeiTools {
) {
const meiData = this.meiData.find((meiData) => meiData.row === row);
if (meiData) {
if (mei !== undefined) {
meiData.mei = mei;
}
if (isValid !== undefined) {
meiData.isValid = isValid;
}
if (errorMsg !== undefined) {
meiData.errorMsg = errorMsg;
// Update this.meiData if it exists
if (mei === '') {
// if the mei cell is empty, remove the row from meiData
this.meiData = this.meiData.filter((data) => data.row !== row);
return;
}
if (mei !== undefined) meiData.mei = mei;
if (isValid !== undefined) meiData.isValid = isValid;
if (errorMsg !== undefined) meiData.errorMsg = errorMsg;
} else {
// Add a new entry to this.meiData if it doesn't exist
this.meiData.push({
row,
mei: mei ?? meiData.mei,
isValid: isValid ?? meiData.isValid,
errorMsg: errorMsg ?? meiData.errorMsg,
mei: mei ?? '',
isValid: isValid ?? null,
errorMsg: errorMsg ?? null,
});
}
}
Expand Down

0 comments on commit 3cb56a9

Please sign in to comment.