mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #120 from gaearon/mutation-index
Update selected index after mutation
This commit is contained in:
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user