Undo feature: fix case where previous state has no state filter (#1124)

* Undo feature: fix case where previous state has no state filter

Fixes https://github.com/chanzuckerberg/cellxgene/issues/1099

When the previous state that the undo feature is trying to roll back to
has no filter state, merging javascript dictionaries result in keeping
the current state filter, preventing the actionFilter from saving the
new state.

* Fix whitespace
This commit is contained in:
Matt Weiden
2020-01-27 08:29:41 -08:00
committed by GitHub
parent d48647a655
commit 8b8a800453
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -85,6 +85,7 @@ const Undoable = (reducer, undoableKeys, options = {}) => {
);
const newPast = [...past];
const newState = newPast.pop();
const newStateFilterState = newState[filterStateKey];
const newFuture = push(future, currentUndoableState);
const nextState = {
...currentState,
@@ -93,6 +94,7 @@ const Undoable = (reducer, undoableKeys, options = {}) => {
[futureKey]: newFuture,
[pendingKey]: null
};
nextState[filterStateKey] = newStateFilterState;
return nextState;
}
+2
View File
@@ -170,6 +170,8 @@ const actionFilter = debug => (state, action, prevFilterState) => {
}
if (
debounceOnActions.has(actionType) &&
prevFilterState !== undefined &&
prevFilterState.prevAction !== undefined &&
shallowObjectEq(action, prevFilterState.prevAction)
) {
return { [actionKey]: "skip", [stateKey]: filterState };