formkit icon indicating copy to clipboard operation
formkit copied to clipboard

Unable to reset form with localstorage plugin

Open zgurea1 opened this issue 2 years ago • 3 comments

Reproduction

https://formkit.link/240690ce7705f58fecdbd2caa8701ad2

Describe the bug

Hello, when you try to reset the form with the localstorage plugin the file object remains even if you completely delete localstorage. So after you submit the form it remains in localstorage and is not deleted.

Environment

• OS: [Windows 10] • Browser [firefox] • Version [1.4.0]

zgurea1 avatar Dec 19 '23 13:12 zgurea1

I’m not seeing this behavior. Can you perhaps give a step-by-step procedure to reproduce it?

justin-schroeder avatar Dec 20 '23 16:12 justin-schroeder

Here we fill the form and we see it in localstorage.

image

After you submit the form, localstorage remain.

image

zgurea1 avatar Dec 21 '23 09:12 zgurea1

I see what you’re saying. I guess I would have a different expectation than you about what should happen here. In my view, the form should reset to it’s initial state which includes the file property{ file: [] }) since the the file input type should always be set to an array even when empty, and the local storage should always be a reflection of that precise state, even if that state is empty.

I think your expectation is that when a form is "empty" there is no local storage at all, is that correct?

If so then the primary question becomes how we determine what the "initial" or "empty" state of the form is. This is complicated by the fact that some inputs provide initial values, such as the file input or multiple checkboxes. Knowing what an "empty" form is becomes rather complex.

Is there any deleterious effect from the local storage existing when the form is in an empty state?

justin-schroeder avatar Dec 29 '23 15:12 justin-schroeder

Closing — please feel free to re-open if there's an argument against the current behavior.

andrew-boyd avatar Mar 07 '24 16:03 andrew-boyd