onhashchange event (e.g. when manually changing the hash in the url, or when it's triggered by the history) doesn't trigger an update on properties that are tied url parameters / hash. So, whenever hash has changed, going back does nothing but change the url.
E.g. the following updates only on page load, but when I go back in the browser, nothing happens (state1.value is only changed when I force refresh with CMD+R):
Side question, is there a way to set hash with a function within Retool? Would be a way to overcome some limitations.
When you say "going back" do you mean going backwards in the browser history to a previous Retool app?
When you have the value linked as both a value to store in the URL and as a value to update, changing the value in the app will also update the value in the URL.
Yes, I meant clicking the back button in the browser (and single page app) - meaning that only the hash changes (to a previous value without page refresh), triggered by the browser rather than the app.
I managed to find a workaround by tying a hidden input to urlparams.hash to capture onhashchange-s.
I cannot seem to get the workaround you reference to work, can you explain it more? I have a text input tied to urlparams.hash.myparam, but when it changes, the change event is not fired on the text input, even though the text changes.