Skip to content

Commit 40bd765

Browse files
committed
replace pushState with replaceState to address navigation issues
1 parent 11af7eb commit 40bd765

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

public/js/sidebar.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ export default class extends Component {
9999
let hash = `#Query_${queryIndex}`;
100100
// if we can guarantee that the browser can handle change in url hash without the page jumping,
101101
// then we update the url hash after scroll. else, hash is only updated on click of next or prev button
102-
if (window.history.pushState) {
103-
window.history.pushState(null, null, hash);
102+
if (window.history.replaceState) {
103+
window.history.replaceState(null, null, hash);
104104
}
105105
this.setState({ queryIndex });
106106
}
@@ -112,12 +112,13 @@ export default class extends Component {
112112
$('html, body').animate({
113113
scrollTop: $(this.hash).offset().top
114114
}, 300);
115-
if (window.history.pushState) {
116-
window.history.pushState(null, null, this.hash);
115+
if (window.history.replaceState) {
116+
window.history.replaceState(null, null, this.hash);
117117
} else {
118118
window.location.hash = this.hash;
119119
}
120120
}
121+
121122
isElementInViewPort(elem) {
122123
const { top, left, right, bottom } = elem.getBoundingClientRect();
123124
return (

0 commit comments

Comments
 (0)