Skip to content

Commit

Permalink
fix(undo-redo): prevent duplicated entries on undo stack
Browse files Browse the repository at this point in the history
fix(undo-redo): prevent duplicated entries on undo stack
  • Loading branch information
rainerhahnekamp authored Jun 20, 2024
2 parents 9ac30eb + e360ee6 commit b4f68af
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libs/ngrx-toolkit/src/lib/with-undo-redo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ SignalStoreFeature<any, any> {
return;
}

//
// Deep Comparison to prevent duplicated entries
// on the stack. This can e.g. happen after an undo
// if the component sends back the undone filter
// to the store.
//
if(JSON.stringify(cand) === JSON.stringify(previous)) {
return;
}

// Clear redoStack after recorded action
redoStack.splice(0);

Expand Down

0 comments on commit b4f68af

Please sign in to comment.