Vulcan
Vulcan copied to clipboard
SmartForm delete two or more items from an array
To recreate this bug:
Clone Vulcan-Starter and run the example-forms package.
Log in, create a new customer, and add multiple addresses to it. (3 or more addresses to make it easiest to see problem in action.)
Edit the newly-created customer and delete two or more addresses. For instance, deleting the last address works as expected, but if you delete one more, it doesn't get removed from the page. This is the bug. (Note that if you submit the form, the address that was not removed from the page will be deleted from the database.)
My fix to this bug is to edit (not in Vulcan-Starter but in Vulcan) packages/vulcan-forms/lib/components/FormNestedArray.jsx.
I’ve added this.forceUpdate() to removeItem (too clunky?) and I also changed isDeleted to what it says in the comment above it, using this.context.deletedValues instead of this.props.deletedValues.
I'll make a PR shortly.
Ack! I seem to have added the same commit twice for some reason, sorry.
I think https://github.com/kevinashworth/Vulcan/commit/f08811f9ee628e9896b116e3686eea4837050423 is the best one?
This bug still persists, but my proposed fix in PR #2392 did not fix it and was, frankly, misguided. So I closed that PR.
I am formulating an alternative fix for this bug....