New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chrome doesn't remember viewmodel after history change #685
Comments
I've created an PR (#686) with the change I made in the first message to fix the persisted viewmodel. |
Hmm, that's strange, we actually introduced that hidden field back in 2015 for exactly this reason - #37. However, I can replicate this issue, it does not work in Chrome (while it works in FF). @tomasherceg You are using Chrome, aren't you? Do you know if it actually ever worked? |
I am sure it worked in Chrome at the time we implemented this. |
I've done some research and on this page they suggest to use the History API. The history API is available in most browser (https://caniuse.com/#search=history) with the exception of <IE9 and Opera Mini. Maybe this is an good alternative for the Edit: However the This is a really complicated issue... 😕 |
I think we can use the History API. The only supported version of IE we support is 11. Actually, I can imagine much more problems with changing the field to |
Alright. I'll try to replace the I also found out that there is a history.state property which returns the current state without having to wait for |
Done. I've created a new PR (#687) that uses the History API. Everything works fine in Edge, Chrome, Firefox and Internet Explorer. Since I don't have an Apple device at home I cannot test if the implementation works on Safari, maybe someone can test this? Also I don't have checked if SPA mode works with the new implementation since this also works with the History API. It should work fine since I combine the old state and the new state, but it's better that someone can verify if this is still working. |
When you leave the page by going back and then going forward, the viewmodel is reset to its initial state.
Example (GIF)
This is because Chrome doesn't remember the value of the
<input type="hidden">
across history states. When we change the following in BodyResourceLinks.cs:then Chrome will remember the viewmodel:
Example (GIF)
When I searched for this issue, I found an issue from 2010 with the same problem (here) in WebForms. So I don't think this behavior won't change in Chrome if it didn't change in 9 years.
What would be the best solution here? Should we change the viewmodel input to an text-field and hide it (with maybe an setting in
DotvvmConfiguration
for compability)?Browser: Google Chrome
Version: 73.0.3683.103 (Official Build) (64-bit)
Dotvvm build commit: dccddcf
Hosting: ASP.Net Core
The text was updated successfully, but these errors were encountered: