fix: remove yellow highlight when modification is reverted to original value

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Vidal Wolf
2026-04-21 09:01:17 +02:00
co-authored by Claude Sonnet 4.6
parent 6a864a4c35
commit 9b861f1c19
+20 -21
View File
@@ -324,34 +324,27 @@ export default function App() {
// Check if the new state is actually different from the original (not the current) // Check if the new state is actually different from the original (not the current)
const isActuallyModified = JSON.stringify(updatedRow) !== JSON.stringify(originalData); const isActuallyModified = JSON.stringify(updatedRow) !== JSON.stringify(originalData);
setAppState(prev => {
const newData = [...prev.data];
newData[rowIndex] = updatedRow;
return { ...prev, data: newData, hasUnsavedChanges: true };
});
if (isActuallyModified) { if (isActuallyModified) {
setPendingRows(prev => { setAppState(prev => {
const next = { const newData = [...prev.data];
...prev, newData[rowIndex] = updatedRow;
[articleNo]: { return { ...prev, data: newData, hasUnsavedChanges: true };
rowIndex,
originalData,
newData: updatedRow,
articleName: String(updatedRow[COLUMNS.ARTICLE_NAME] || articleNo),
}
};
setAppState(app => ({ ...app, hasUnsavedChanges: true }));
return next;
}); });
setPendingRows(prev => ({
...prev,
[articleNo]: {
rowIndex,
originalData,
newData: updatedRow,
articleName: String(updatedRow[COLUMNS.ARTICLE_NAME] || articleNo),
}
}));
setRowStatuses(prev => ({ ...prev, [articleNo]: 'pending' })); setRowStatuses(prev => ({ ...prev, [articleNo]: 'pending' }));
} else { } else {
// It was changed back to its original state - remove from pending // Changed back to original state - remove from pending
setPendingRows(prev => { setPendingRows(prev => {
const n = { ...prev }; const n = { ...prev };
delete n[articleNo]; delete n[articleNo];
const stillHasChanges = Object.keys(n).length > 0;
setAppState(app => ({ ...app, hasUnsavedChanges: stillHasChanges }));
return n; return n;
}); });
setRowStatuses(prev => { setRowStatuses(prev => {
@@ -359,6 +352,12 @@ export default function App() {
delete n[articleNo]; delete n[articleNo];
return n; return n;
}); });
setAppState(prev => {
const newData = [...prev.data];
newData[rowIndex] = updatedRow;
const stillHasChanges = Object.keys(pendingRows).filter(k => k !== articleNo).length > 0;
return { ...prev, data: newData, hasUnsavedChanges: stillHasChanges };
});
} }
setEditingRowIndex(null); setEditingRowIndex(null);
}; };