Update item form keeps deleted input with cancel and generally doesn't work while item is markes as purchased #864
-
Hi, My other problem is that I get an error message when I want to edit an item which is marked as purchased.
I have committed and pushed my current status in this PR. Thank you for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
The second problem occurs cause the function was not passed as a prop. We have fixed that already. 🙂 |
Beta Was this translation helpful? Give feedback.
-
I just had a quick look. I logged the |
Beta Was this translation helpful? Give feedback.
-
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:
Why This Solves the Problem with Here’s why your
Try implementing this mode approach. This way, you’ll have your form displaying the initial values correctly every time you open it for editing, without any leftover states from previous attempts. PS: With my suggested change, you can make the |
Beta Was this translation helpful? Give feedback.
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:
index.js
, which can be either default, edit,…