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
+10 -11
View File
@@ -324,15 +324,13 @@ export default function App() {
// Check if the new state is actually different from the original (not the current)
const isActuallyModified = JSON.stringify(updatedRow) !== JSON.stringify(originalData);
if (isActuallyModified) {
setAppState(prev => {
const newData = [...prev.data];
newData[rowIndex] = updatedRow;
return { ...prev, data: newData, hasUnsavedChanges: true };
});
if (isActuallyModified) {
setPendingRows(prev => {
const next = {
setPendingRows(prev => ({
...prev,
[articleNo]: {
rowIndex,
@@ -340,18 +338,13 @@ export default function App() {
newData: updatedRow,
articleName: String(updatedRow[COLUMNS.ARTICLE_NAME] || articleNo),
}
};
setAppState(app => ({ ...app, hasUnsavedChanges: true }));
return next;
});
}));
setRowStatuses(prev => ({ ...prev, [articleNo]: 'pending' }));
} else {
// It was changed back to its original state - remove from pending
// Changed back to original state - remove from pending
setPendingRows(prev => {
const n = { ...prev };
delete n[articleNo];
const stillHasChanges = Object.keys(n).length > 0;
setAppState(app => ({ ...app, hasUnsavedChanges: stillHasChanges }));
return n;
});
setRowStatuses(prev => {
@@ -359,6 +352,12 @@ export default function App() {
delete n[articleNo];
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);
};