Skip to content

Commit

Permalink
Only try to restore table state from hash when there is one
Browse files Browse the repository at this point in the history
  • Loading branch information
carlhoerberg committed Jan 8, 2024
1 parent 0c3bd0a commit dae5a82
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions static/js/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ class DataSource {
} catch (e) {
console.error(`Failed to load cached query state: ${e}`, cachedState)
}
} else {
this._setStateFromHash()
}
this._setStateFromHash()
window.addEventListener('hashchange', evt => {
this._setStateFromHash()
this.reload({ updateState: false })
Expand All @@ -86,8 +85,10 @@ class DataSource {
}

_setStateFromHash () {
const urlParams = Object.fromEntries(new URLSearchParams(window.location.hash.substring(1)).entries())
this._setState(urlParams)
if (window.location.hash.length > 0) {
const urlParams = Object.fromEntries(new URLSearchParams(window.location.hash.substring(1)).entries())
this._setState(urlParams)
}
}

_setState (properties = {}) {
Expand Down

0 comments on commit dae5a82

Please sign in to comment.