Skip to content

Commit 103440f

Browse files
committed
properly detect navigation type in search script; don't restore previous search if type is not available
1 parent 84fd11b commit 103440f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/js/vendor/docsearch.bundle.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,16 @@
6464
}
6565

6666
function reactivateSearch (e) {
67-
var navigationType = (window.performance.navigation || {}).type
68-
if (navigationType && navigationType !== FORWARD_BACK_TYPE) return
69-
if (e.persisted && !isClosed(this)) {
70-
this.$input.focus()
71-
this.$input.val(this.getVal())
72-
} else if (window.sessionStorage.getItem('docs:restore-search-on-back') === 'true') {
73-
restoreSearch.call(this)
67+
var navigation = window.performance.navigation || {}
68+
if ('type' in navigation) {
69+
if (navigation.type !== FORWARD_BACK_TYPE) {
70+
return
71+
} else if (e.persisted && !isClosed(this)) {
72+
this.$input.focus()
73+
this.$input.val(this.getVal())
74+
} else if (window.sessionStorage.getItem('docs:restore-search-on-back') === 'true') {
75+
restoreSearch.call(this)
76+
}
7477
}
7578
window.sessionStorage.removeItem('docs:restore-search-on-back')
7679
}

0 commit comments

Comments
 (0)