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) // 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);
if (isActuallyModified) {
setAppState(prev => { setAppState(prev => {
const newData = [...prev.data]; const newData = [...prev.data];
newData[rowIndex] = updatedRow; newData[rowIndex] = updatedRow;
return { ...prev, data: newData, hasUnsavedChanges: true }; return { ...prev, data: newData, hasUnsavedChanges: true };
}); });
setPendingRows(prev => ({
if (isActuallyModified) {
setPendingRows(prev => {
const next = {
...prev, ...prev,
[articleNo]: { [articleNo]: {
rowIndex, rowIndex,
@@ -340,18 +338,13 @@ export default function App() {
newData: updatedRow, newData: updatedRow,
articleName: String(updatedRow[COLUMNS.ARTICLE_NAME] || articleNo), articleName: String(updatedRow[COLUMNS.ARTICLE_NAME] || articleNo),
} }
}; }));
setAppState(app => ({ ...app, hasUnsavedChanges: true }));
return next;
});
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);
}; };