Fix unexpected history back navigations (#1424)
This commit is contained in:
parent
b5542462ac
commit
4082143e10
@ -124,18 +124,20 @@ export default function useHistoryBack(
|
||||
} else {
|
||||
const prev = prevHashes || [];
|
||||
if (prev.length < hashes.length) {
|
||||
const index = ++historyState.currentIndex;
|
||||
historyState.currentIndexes.push(index);
|
||||
setTimeout(() => {
|
||||
const index = ++historyState.currentIndex;
|
||||
historyState.currentIndexes.push(index);
|
||||
|
||||
window.history.pushState({
|
||||
index,
|
||||
state: currentState,
|
||||
}, '', `#${hashes[hashes.length - 1]}`);
|
||||
window.history.pushState({
|
||||
index,
|
||||
state: currentState,
|
||||
}, '', `#${hashes[hashes.length - 1]}`);
|
||||
|
||||
indexHashRef.current.push({
|
||||
index,
|
||||
hash: hashes[hashes.length - 1],
|
||||
});
|
||||
indexHashRef.current.push({
|
||||
index,
|
||||
hash: hashes[hashes.length - 1],
|
||||
});
|
||||
}, 0);
|
||||
} else {
|
||||
const delta = prev.length - hashes.length;
|
||||
if (isHashChangedFromEvent.current) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user