react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

Use index for value in SelectWidget

Open tdamsma opened this issue 4 years ago • 2 comments

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.

tdamsma avatar Dec 30 '19 14:12 tdamsma

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.

tdamsma avatar Jan 12 '20 21:01 tdamsma

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

epicfaace avatar Jan 12 '20 22:01 epicfaace