-
Notifications
You must be signed in to change notification settings - Fork 9
Description
@AndreyChernykh had some concerns with the design of the <Filter /> component's API.
Imagine a Filter that can filter on two drop-down fields: favourite colour (options are: blue, red, orange) and favourite animal (options are: cat, dog, eagle, dragon).
The data prop that is passed into <Filter /> is an array of objects, where each option must exist in the array or it will not be an <option> in the <select>. So you must pass in at least this data:
data = [
{colour: blue, animal: cat},
{colour: red, animal: cat},
{colour: orange, animal: cat},
{colour: orange, animal: dog},
{colour: orange, animal: eagle},
{colour: orange, animal: dragon},
]
This can be a pain for cases like mine, where I have to filter on five (and soon eight) drop-down fields, and each could have dozens of options.
Andrey was thinking instead the API could incorporate options, so they don't have to be duplicated over and over again (like "orange" is above):
<Filter
options={{colour: [blue, red, orange], animal: [cat, dog, eagle, dragon]}}
...
/>
cc: @allison-c