Merge pull request #120 from gaearon/mutation-index

Update selected index after mutation
This commit is contained in:
Brian Vaughn
2019-04-10 09:35:00 -07:00
committed by GitHub
@@ -407,6 +407,20 @@ function reduceOwnersState(store: Store, state: State, action: Action): State {
ownerStackIndex = ownerStack.length - 1;
}
}
if (selectedElementID !== null) {
// Mutation might have caused the index of this ID to shift.
selectedElementIndex = _ownerFlatTree.indexOf(selectedElementID);
}
} else {
if (selectedElementID !== null) {
// Mutation might have caused the index of this ID to shift.
selectedElementIndex = store.getIndexOfElementID(selectedElementID);
}
}
if (selectedElementIndex === -1) {
// If we couldn't find this ID after mutation, unselect it.
selectedElementIndex = null;
selectedElementID = null;
}
break;
case 'RESET_OWNER_STACK':