flipbyte / formik-json-schema

Easily create react forms using JSON / Javascript Object
MIT License
152 stars 40 forks source link

Position prop in elements not used? #39

Closed compojoom closed 5 years ago

compojoom commented 5 years ago

Describe the bug

The elements definition in the schema is an Object. The js engine however is not required to output the props in the order they are defined in the source code. Chrome seems to be outputing the elements in the defined order, but on iOS my elements end up in the wrong order.

In the repository readme we have a position prop and I assumed that it's used to define the order of the elements. I did a fast search through the code base and I couldn't find where it's used?

I use the form container for now, so adding a _.map(_.orderBy(elements, 'position') ... seems to fix my issue. Shall I create a pull request or is there something I'm missing?

easeq commented 5 years ago

The idea was to handle element positioning within formik-json, but then we dropped the idea because it seems unnecessary to handle positioning within formik-json as the schema object is not usually overridden to have the elements out of order.

The schema object should already be prepared to have all the elements in order before passing it to formik-json to avoid unnecessary processing of field order.

I must have missed to update the README.