fix off by 1 error in navigation history
This commit is contained in:
parent
f12e3551e2
commit
a9113369ef
1 changed files with 2 additions and 7 deletions
|
@ -41,17 +41,12 @@ reducers[types.HISTORY_NAVIGATE] = (state, action) => {
|
||||||
|
|
||||||
let newState = {};
|
let newState = {};
|
||||||
|
|
||||||
const path = action.data.url,
|
const path = action.data.url;
|
||||||
previousIndex = index - 1;
|
|
||||||
|
|
||||||
// Check for duplicated
|
// Check for duplicated
|
||||||
if (action.data.index >= 0) {
|
if (action.data.index >= 0) {
|
||||||
newState.index = action.data.index;
|
newState.index = action.data.index;
|
||||||
} else if (
|
} else if (!stack[index] || stack[index].path !== path) {
|
||||||
previousIndex === -1 ||
|
|
||||||
!stack[previousIndex] ||
|
|
||||||
stack[previousIndex].path !== path
|
|
||||||
) {
|
|
||||||
newState.stack = [...stack.slice(0, index + 1), { path, scrollY: 0 }];
|
newState.stack = [...stack.slice(0, index + 1), { path, scrollY: 0 }];
|
||||||
newState.index = newState.stack.length - 1;
|
newState.index = newState.stack.length - 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue