Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/core/src/reducers/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import cloneDeep from 'lodash/cloneDeep';
import setFp from 'lodash/fp/set';
import unsetFp from 'lodash/fp/unset';
import get from 'lodash/get';
import filter from 'lodash/filter';
import isEqual from 'lodash/isEqual';
Expand Down Expand Up @@ -285,11 +286,17 @@ export const coreReducer: Reducer<JsonFormsCore, CoreActions> = (
} else {
const oldData: any = get(state.data, action.path);
const newData = action.updater(cloneDeep(oldData));
const newState: any = setFp(
action.path,
newData,
state.data === undefined ? {} : state.data
);
let newState: any
if (newData !== undefined) {
newState = setFp(
action.path,
newData,
state.data === undefined ? {} : state.data
);
}
else {
newState = unsetFp(action.path, state.data === undefined ? {} : state.data);
}
const errors = validate(state.validator, newState);
return {
...state,
Expand Down