-
Notifications
You must be signed in to change notification settings - Fork 399
DynamicForm - Custom sorting #1802
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
Conversation
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.
Thanks for this PR @srpmtt!
I've added a few suggestions, let me know if you have any questions.
const { customFormatting, hiddenByFormula, infoErrorMessages, isSaving } = this.state; | ||
|
||
if (this.props.fieldOrder) { | ||
fieldCollection = this.sortFields(fieldCollection, this.props.fieldOrder) |
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.
Is there a reason to sort fields during rendering instead of doing it during mouting / fieldOrder
prop update?
From my perspective, this could be done in the getListInformation
method, triggered in mount / update event, to avoid unnecessary re-ordering and which is already doing all the work around list / list item / fields.
let {fieldCollection} = this.state | ||
const { customFormatting, hiddenByFormula, infoErrorMessages, isSaving } = this.state; | ||
|
||
if (this.props.fieldOrder) { |
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.
It would be better to check the length of the array (as it could be empty if controlled outside for example) to avoid unnecessary Map set.
Merged manually, thank you! |
DynamicForm custom sorting.
Added a new optional prop fieldOrder (string[]), the values are the fields internal names.