-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
FIO-9072: required validation triggered on form load #5846
Changes from 5 commits
1e6bff5
ae658f9
7565f58
796fec1
7f5a910
9041a67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2810,7 +2810,6 @@ | |
return; | ||
} | ||
_.set(this._data, this.key, value); | ||
return; | ||
} | ||
|
||
/** | ||
|
@@ -2969,7 +2968,7 @@ | |
|
||
/** | ||
* Returns if the value (e.g. array) should be divided between several inputs | ||
* @returns {boolean} | ||
Check warning on line 2971 in src/components/_classes/component/Component.js GitHub Actions / setup
|
||
*/ | ||
isSingleInputValue() { | ||
return false; | ||
|
@@ -3388,14 +3387,15 @@ | |
if (flags.silentCheck) { | ||
return []; | ||
} | ||
let dirty = this.dirty || flags.dirty | ||
if (this.options.alwaysDirty) { | ||
flags.dirty = true; | ||
dirty = true; | ||
} | ||
if (flags.fromSubmission && this.hasValue(data)) { | ||
flags.dirty = this.pristine && this.component.protected ? false : true; | ||
if (flags.fromSubmission && !_.isUndefined(_.get(flags?.submission?.data, this.key)) && !(this.pristine && this.protected)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _.get(submission.data, this.key) not always the way to fetch the correct data for a component. Particularly the Checkbox components configured as Radio components would fail here. Why can we not use "this.hasValue"? It looks like you can pass data to it... maybe change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hasValue(data) { |
||
dirty = this.pristine && this.component.protected ? false : true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to me that this.protected is always undefined. I was not able to find a place where it is set to true/false. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure. It looks like I accidentally added this when trying to resolve merge conflicts. I will remove it |
||
} | ||
this.setDirty(flags.dirty); | ||
return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission); | ||
this.setDirty(dirty); | ||
return this.setComponentValidity(errors, dirty, flags.silentCheck, flags.fromSubmission); | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -927,22 +927,24 @@ export default class NestedComponent extends Field { | |
|
||
setNestedValue(component, value, flags = {}) { | ||
component._data = this.componentContext(component); | ||
let componentFlags = {...flags}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary anymore now that we are no longer mutating the "dirty" property? I would prefer to not have to clone if we don't need to. |
||
|
||
if (component.type === 'button') { | ||
return false; | ||
} | ||
if (component.type === 'components') { | ||
if (component.tree && component.hasValue(value)) { | ||
return component.setValue(_.get(value, component.key), flags); | ||
return component.setValue(_.get(value, component.key), componentFlags); | ||
} | ||
return component.setValue(value, flags); | ||
return component.setValue(value, componentFlags); | ||
} | ||
else if (value && component.hasValue(value)) { | ||
return component.setValue(_.get(value, component.key), flags); | ||
return component.setValue(_.get(value, component.key), componentFlags); | ||
} | ||
else if ((!this.rootPristine || component.visible) && component.shouldAddDefaultValue) { | ||
flags.noValidate = !flags.dirty; | ||
flags.resetValue = true; | ||
return component.setValue(component.defaultValue, flags); | ||
componentFlags.noValidate = !componentFlags.dirty; | ||
componentFlags.resetValue = true; | ||
return component.setValue(component.defaultValue, componentFlags); | ||
} | ||
} | ||
|
||
|
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.
Why is this necessary? I don't like the idea of creating a clone of the submission object here so it can be passed along to the setValue method. Is this absolutely necessary?
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.
This is so that the explicit submission can be used to determine whether or not to show validation. I could not use this.data or this.submission because these are filled with this.empty value. e.g. button components get false, textfield components get and empty string. I need to know the exact submission at the time it was inputted to determine if it was given an empty value or if it was not even a property in the submission json.