Skip to content

Update item form keeps deleted input with cancel and generally doesn't work while item is markes as purchased #864

Answered by ahohnsen
laurasliwa asked this question in Web
Discussion options

You must be logged in to vote

Hey Laura,

When you click the edit button, your form loads with the item’s details. However, if you clear out any input field, click cancel, and then return to the edit form, those previously emptied fields remain blank. This happens because the form stays mounted the entire time, so some fields hold onto their last state instead of resetting to their initial values.

Solution: Use a Mode State to Toggle Form Visibility

To resolve this, you can toggle the form visibility based on a mode state. By controlling when the form is shown, you can ensure it always appears freshly reset. Here’s how it works:

  1. Create a Mode State: Set a mode state in your index.js, which can be either default, edit,…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by laurasliwa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
3 participants