Skip to content

Commit e360ee6

Browse files
committed
fix(undo-redo): prevent duplicated entries on undo stack
1 parent f8afdc0 commit e360ee6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libs/ngrx-toolkit/src/lib/with-undo-redo.ts

+10
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ SignalStoreFeature<any, any> {
161161
return;
162162
}
163163

164+
//
165+
// Deep Comparison to prevent duplicated entries
166+
// on the stack. This can e.g. happen after an undo
167+
// if the component sends back the undone filter
168+
// to the store.
169+
//
170+
if(JSON.stringify(cand) === JSON.stringify(previous)) {
171+
return;
172+
}
173+
164174
// Clear redoStack after recorded action
165175
redoStack.splice(0);
166176

0 commit comments

Comments
 (0)