Skip to content

Commit

Permalink
Do not clobber existing tab stack if possible (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcdonald-ut authored and aksonov committed Jun 13, 2017
1 parent 473665f commit 58fe836
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,20 @@ function inject(state, action, props, scenes) {
resetHistoryStack(state.children[ind]);
}

state.children[ind] = getInitialState(
props,
scenes,
state.index,
{ ...action, parentIndex: state.children[ind].parentIndex },
);
const activeChild = state.children[state.index];
const incomingChild = state.children[ind];

const incomingChildHadTabs = incomingChild.tabs;
const incomingChildWasActive = incomingChild.children.length > 1;
const activeChildIsIncomingChild = activeChild.sceneKey === action.key;
if (incomingChildHadTabs || !incomingChildWasActive || activeChildIsIncomingChild) {
state.children[ind] = getInitialState(
{ ...props },
scenes,
state.index,
{ ...action, parentIndex: state.children[ind].parentIndex },
);
}

return { ...state, index: ind };
}
Expand Down

0 comments on commit 58fe836

Please sign in to comment.