Skip to content

Commit

Permalink
Merge pull request #123 from DDMAL/remove-clear-mei
Browse files Browse the repository at this point in the history
fix: remove `meiData` entry after clearing cell
  • Loading branch information
kunfang98927 authored Jul 15, 2024
2 parents ca06fd8 + 3cb56a9 commit b83f170
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 b83f170

Please sign in to comment.