You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am making a multi-page form, and I want the user to be able to move back and forth between the pages. Moreover, when the user moves back to a previous page, I want the form to be automatically re-filled with whatever the user had written before (during this session).
To achieve this, I am relying on the localStorage of the browser:
whenever the user is typing, the input is saved on the localStorage
when a page is initialized, the existing data is retrieved from the localStorage
To retrieve the data, Elm sends a request to the browser (by using a command during page initialization). Then, Elm waits for a response from the browser (by using a subscription).
I have observed the following behaviour:
if the user lands on the page directly (i.e., by clicking a link or typing the URL manually), the subscription works correctly
if the user lands on the page by navigating back to it (i.e., by pressing the BACK button of the browser), the subscription does not work
After much debugging, I finally realized this bug only occurs when using the most recent Elm core libraries. Downgrading to older core libraries seems to fix the bug.
To demonstrate this, I created a very basic project, which you can find here: https://github.com/miki-c/elm-bug
Here you will find two elm.json files: one with the older core libraries, and the other with the more recent libraries. The bug will show up when running the app with the recent elm.json file, but not when running it with the old elm.json file. You can find more instructions in the README of the project.
FAQ:
1. Which libraries are causing the bug exactly?
I don't know. I cannot run precise experiments by manually changing their version one by one, because the libraries are all interdependent, and manually editing elm.json throws an error. You can compare the two different elm.json files in the project to find which libraries have been updated. Though, I have a feeling it's one of these:
elm/core: 1.0.0 -> 1.0.5
elm/http: 1.0.0 -> 2.0.0
elm/browser: 1.0.0 -> 1.0.1
2. What is breaking exactly?
By printing some logs, I discovered that the request is successfully sent by Elm and received by the browser. Then, the response is successfully sent by the browser, but it is not received by Elm. It is as if the subscription was not listening at all.
The text was updated successfully, but these errors were encountered:
I am making a multi-page form, and I want the user to be able to move back and forth between the pages. Moreover, when the user moves back to a previous page, I want the form to be automatically re-filled with whatever the user had written before (during this session).
To achieve this, I am relying on the localStorage of the browser:
To retrieve the data, Elm sends a request to the browser (by using a command during page initialization). Then, Elm waits for a response from the browser (by using a subscription).
I have observed the following behaviour:
After much debugging, I finally realized this bug only occurs when using the most recent Elm core libraries. Downgrading to older core libraries seems to fix the bug.
To demonstrate this, I created a very basic project, which you can find here: https://github.com/miki-c/elm-bug
Here you will find two elm.json files: one with the older core libraries, and the other with the more recent libraries. The bug will show up when running the app with the recent elm.json file, but not when running it with the old elm.json file. You can find more instructions in the README of the project.
FAQ:
1. Which libraries are causing the bug exactly?
I don't know. I cannot run precise experiments by manually changing their version one by one, because the libraries are all interdependent, and manually editing elm.json throws an error. You can compare the two different elm.json files in the project to find which libraries have been updated. Though, I have a feeling it's one of these:
2. What is breaking exactly?
By printing some logs, I discovered that the request is successfully sent by Elm and received by the browser. Then, the response is successfully sent by the browser, but it is not received by Elm. It is as if the subscription was not listening at all.
The text was updated successfully, but these errors were encountered: