Skip to content

Commit

Permalink
Add new tabs on top, when closing switch to upper tab, or last consta…
Browse files Browse the repository at this point in the history
…nt, closes #1023
  • Loading branch information
fasterthanlime committed Nov 30, 2016
1 parent a30d369 commit baca179
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions appsrc/reducers/session/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ export default handleActions<ISessionNavigationState, any>({
const newTabs = {
constant,
transient: [
...transient,
newTab,
...transient,
],
};

Expand Down Expand Up @@ -212,14 +212,13 @@ export default handleActions<ISessionNavigationState, any>({

let newId = id;
if (id === closeId) {
if (newTransient.length > 0) {
const newIds = constant.concat(newTransient);
const numNewIds = newIds.length;
const newIds = constant.concat(newTransient);

const nextIndex = Math.min(index, numNewIds - 1);
newId = newIds[nextIndex];
} else {
const nextIndex = Math.max(0, index - 1);
if (nextIndex < constant.length) {
newId = state.lastConstant;
} else {
newId = newIds[nextIndex];
}
}

Expand Down

0 comments on commit baca179

Please sign in to comment.