From 19895b8b4c58f9ba7b76f0ba83d411739e718f61 Mon Sep 17 00:00:00 2001 From: Karlie Fang Date: Thu, 11 Jul 2024 22:39:40 -0400 Subject: [PATCH 1/2] fix: a cell without change don't alter save status Refs: #115 --- src/Editor/CressTable.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Editor/CressTable.ts b/src/Editor/CressTable.ts index 6cace21..dcebf71 100644 --- a/src/Editor/CressTable.ts +++ b/src/Editor/CressTable.ts @@ -151,7 +151,13 @@ export class CressTable { private initChangeListener() { changeHooks.forEach((hook) => { this.table.addHook(hook, (source) => { - if (source != 'loadData') setSavedStatus(false); + if (source != 'loadData') { + if (hook === 'afterChange') { + if (source[0][2] !== source[0][3]) setSavedStatus(false); + } else { + setSavedStatus(false); + } + } }); }); } From 177785b85eae004a126f0f9fd096d91f7bd57895 Mon Sep 17 00:00:00 2001 From: Karlie Fang Date: Fri, 12 Jul 2024 12:15:52 -0400 Subject: [PATCH 2/2] fix: set variables for `oldValue` and `newValue` --- src/Editor/CressTable.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Editor/CressTable.ts b/src/Editor/CressTable.ts index dcebf71..064f5d6 100644 --- a/src/Editor/CressTable.ts +++ b/src/Editor/CressTable.ts @@ -153,7 +153,9 @@ export class CressTable { this.table.addHook(hook, (source) => { if (source != 'loadData') { if (hook === 'afterChange') { - if (source[0][2] !== source[0][3]) setSavedStatus(false); + const oldValue = source[0][2]; + const newValue = source[0][3]; + if (oldValue !== newValue) setSavedStatus(false); } else { setSavedStatus(false); }