From a9113369ef750f2c9d294f2031e5f21f39360e1d Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Thu, 31 Aug 2017 08:59:29 -0400 Subject: [PATCH] fix off by 1 error in navigation history --- ui/js/reducers/navigation.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ui/js/reducers/navigation.js b/ui/js/reducers/navigation.js index eca9bd008..821db9183 100644 --- a/ui/js/reducers/navigation.js +++ b/ui/js/reducers/navigation.js @@ -41,17 +41,12 @@ reducers[types.HISTORY_NAVIGATE] = (state, action) => { let newState = {}; - const path = action.data.url, - previousIndex = index - 1; + const path = action.data.url; // Check for duplicated if (action.data.index >= 0) { newState.index = action.data.index; - } else if ( - previousIndex === -1 || - !stack[previousIndex] || - stack[previousIndex].path !== path - ) { + } else if (!stack[index] || stack[index].path !== path) { newState.stack = [...stack.slice(0, index + 1), { path, scrollY: 0 }]; newState.index = newState.stack.length - 1; }