final-form / final-form/react-final-form-arrays

React Final Forms is the best Form library and uhh... how do you sort Field Arrays before and after adding elements???

Open
#121 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
210
Forks
69
PR merge metrics
No merged PRs in 30d

Description

Been trying all kinds of things to have my `FieldArray` elements sort when there are updates.
I created an example using the Simple Example (see: Sandbox Link below)

Basically just added an existing array of customers that is used as the initial data for the form. The data is intentionally out of order, but that is beside the point. When you add a NEW customer, I would like them to get inserted into the "correct" location, ie: displayed in alphabetical order according to their last name.

I've imported some utilities from Ramda to perform the sorting, and you can uncomment the console logging to see that the data IS getting sorted correctly, but uhhh... the list does not appear that way.

### Are you submitting a **bug report** or a **feature request**?

might be a bug report but might also just be a cry for help?
But it could also be a feature request for adding the ability to pass a custom sorting function that would be used at the optimum time to sort the data being displayed.

### What is the current behavior?

can not figure out how to get `FieldArray` elements to sort both on initial render and when new elements are added

### What is the expected behavior?

that the list would sort upon render even after new data is added

### Sandbox Link

https://codesandbox.io/s/react-final-form-field-arrays-thp3q

### What's your environment?

temperate rainforest (British Columbia, Canada) as well as W10, PhpStorm

### Other information

Thanks for making the best form library out there!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.