diff options
Diffstat (limited to 'src/reducers/completion.js')
-rw-r--r-- | src/reducers/completion.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/reducers/completion.js b/src/reducers/completion.js index a706988..a8a6444 100644 --- a/src/reducers/completion.js +++ b/src/reducers/completion.js @@ -24,7 +24,10 @@ const nextSelection = (state) => { const prevSelection = (state) => { if (state.groupSelection < 0) { - return [0, 0]; + return [ + state.groups.length - 1, + state.groups[state.groups.length - 1].items.length - 1 + ]; } if (state.groupSelection === 0 && state.itemSelection === 0) { return [-1, -1]; @@ -41,7 +44,9 @@ export default function reducer(state = defaultState, action = {}) { switch (action.type) { case actions.COMPLETION_SET_ITEMS: return Object.assign({}, state, { - groups: action.groups + groups: action.groups, + groupSelection: -1, + itemSelection: -1, }); case actions.COMPLETION_SELECT_NEXT: { let next = nextSelection(state); @@ -57,5 +62,7 @@ export default function reducer(state = defaultState, action = {}) { itemSelection: next[1], }); } + default: + return defaultState; } } |