react-jsonschema-form
react-jsonschema-form copied to clipboard
Use index for value in SelectWidget
This PR changes the way options are selected in the SelectWidget by using the options array index instead of a serializing the selected value to the DOM (cast to string). This allows removal of a lot of hacky code to guess type of deserialized values, and also allows for selecting complete objects via a dropdown, addressing #1494.
I've added a playground example. I haven't looked at fixing the tests yet as would like feedback on the approach first.
This would be a great improvement!
Good to hear, what can I do help this get landed? Not really sure how to proceed. Lots of tests are failing, but as they are written now they would become kind of pointless as most tests I saw focus on checking the values in the DOM render which are just a bunch of integers with this change.
It seems that many of the tests are failing because o
is undefined in .map(o => o.value)
: https://github.com/rjsf-team/react-jsonschema-form/blob/master/packages/core/src/components/widgets/SelectWidget.js#L43