-
Steps to reproduce
<div x-data="{ testInput3 : $persist('default value') }">
<input x-model="testInput3" type="text">
<p>Value: <span x-text="testInput3"></span></p>
</div>
Expected behaviorWhen Tab 1 is restored, it should show "value 2" (the current value from localStorage that was set in Tab 2) Firefox behavior
Chromium behavior
This suggests that Firefox triggers Alpine's reactivity system when browser restores input value, while Chrome doesn't propagate this restored value to Alpine's state. Both bad. This may seem like a small problem. But I used it not with If you use logging in |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
I agree that the inconsistence between firefox and chrome is weird but the behaviour you see in firefox is what I would expect. |
Beta Was this translation helpful? Give feedback.
-
Found a hack that helps curb unwanted behavior. Not perfect, but at least something. window.addEventListener('pageshow', function (event) {
if (event.persisted || performance.getEntriesByType("navigation")[0].type === 'back_forward') {
document.documentElement.innerHTML = '';
location.reload();
}
}, false); Thanks @SimoTod |
Beta Was this translation helpful? Give feedback.
-
I think you can also try yo set Cache-control to no store to prevent your
browser to take a snapshot of your page and force a clean page every time.
…On Sun, 23 Feb 2025, 12:04 Jipok, ***@***.***> wrote:
Found a hack that helps curb unwanted behavior. Not perfect, but at least
something.
window.addEventListener('pageshow', function (event) {
if (event.persisted || performance.getEntriesByType("navigation")[0].type === 'back_forward') {
document.documentElement.innerHTML = '';
location.reload();
}}, false);
Thanks @SimoTod <https://github.com/SimoTod>
—
Reply to this email directly, view it on GitHub
<#4552 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAJRWJ4B2YKUH32TWDDBQ32RG2LZAVCNFSM6AAAAABXVJ5UN2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMRZGEYTSNI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Found a hack that helps curb unwanted behavior. Not perfect, but at least something.
Thanks @SimoTod