Skip to content

Commit

Permalink
Fix clear errors in parent of array after child change (#4014)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasztomys authored and erikras committed May 31, 2018
1 parent 55c6ab3 commit bfc00b5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/deleteInWithCleanUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ function createCreateDeleteInWithCleanUp<DIM, DIL>(
// array path
const pathTokens = toPath(path)
pathTokens.pop()
const parent = getIn(state, pathTokens.join('.'))
return parent ? setIn(state, path) : state
if(getIn(state, pathTokens.join('.'))) {
setIn(state, path)
}
}

let result: DIM | DIL = state
Expand All @@ -37,12 +38,8 @@ function createCreateDeleteInWithCleanUp<DIM, DIL>(
const dotIndex = path.lastIndexOf('.')
if (dotIndex > 0) {
const parentPath = path.substring(0, dotIndex)
if (parentPath[parentPath.length - 1] !== ']') {
const parent = getIn(result, parentPath)
if (deepEqual(parent, empty)) {
return deleteInWithCleanUp(result, parentPath)
}
}
const parent = getIn(result, parentPath)
return deleteInWithCleanUp(result, parentPath)
}
return result
}
Expand Down

0 comments on commit bfc00b5

Please sign in to comment.