Skip to content

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

Merged
merged 2 commits into from
Aug 16, 2024
Merged

DynamicForm - Custom sorting #1802

merged 2 commits into from
Aug 16, 2024

Conversation

srpmtt
Copy link
Contributor

@srpmtt srpmtt commented Apr 6, 2024

Q A
Bug fix? [ ]
New feature? [ X ]
New sample? [ ]
Related issues? mentioned in #1416

DynamicForm custom sorting.
Added a new optional prop fieldOrder (string[]), the values are the fields internal names.

Copy link
Collaborator

@michaelmaillot michaelmaillot left a 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)
Copy link
Collaborator

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) {
Copy link
Collaborator

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.

@srpmtt srpmtt requested a review from michaelmaillot August 15, 2024 19:13
@michaelmaillot michaelmaillot merged commit 34d9c48 into pnp:dev Aug 16, 2024
1 check passed
@michaelmaillot
Copy link
Collaborator

Merged manually, thank you!

@michaelmaillot michaelmaillot added this to the 3.20.0 milestone Aug 16, 2024
@srpmtt srpmtt deleted the df-custom-sort branch August 16, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants