-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Destroy task #1409
Destroy task #1409
Conversation
default: | ||
parsed[key] = val; | ||
if (element === undefined) { | ||
delete this.state.formState[key]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to directly manipulate the state here. Instead we need to eventually pass the new data to setState
. We use the return value from this method to set the state correctly on line 153. So, I think if the element is undefined we can just skip that element and move on. It will then not end up in parsed
and will be later removed from the state when we do setState
let formState = this.parseFormState(this.state.formState); | ||
this.props.onConfirm(formState); | ||
if (!this.props.keepCurrentFormState) { | ||
const formState = {}; | ||
formState = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the const because the variable is block scoped and so it would never be saved properly here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, saw that after and deleted my comment, didn't have the diff open wide enough
Updated to ignore unused fields. I tried removing the state entirely and getting it working with just props, but it didn't work easily. It seems possible though. We should re-visit it at another time. |
Looking good on stable, LGTM |
This fixes an issue with how the form elements were mapped. If a prior form field isn't used in an updated form, it would throw an undefined error when it tried to access the non-existent field. I tried finding a good way to remove the field without disrupting the rest of the uses of the FormModal component, but I could not find one. Right now it just removes as unused fields from the mapping. If you see a better method, I could def use it
@ssalinas