jquense / react-widgets

Polished, feature rich, accessible form inputs built with React
http://jquense.github.io/react-widgets/
MIT License
2.34k stars 395 forks source link

DropdownList: disabled property does not work for an array of objects. #1083

Closed evpozdniakov closed 3 years ago

evpozdniakov commented 3 years ago

It works fine for the case like in your example page: image

But if the data property is an array of objects like { id, name } then there is no way to disable a particular item.

Here is an example:

<DropdownList<{ id: string, name: string }>
  data={[{ id: 'one', name: 'One' }, { id: 'two', name: 'Two' }, { id: 'three', name: 'Three' }]}
  dataKey="id"
  disabled={[{ id: 'one', name: 'One' }, { id: 'two', name: 'Two' }]}
  open
  textField="name"
/>

The result: image

jquense commented 3 years ago

that is because it does a === comparison of the objects in the array, for performance reasons. You should use the actual instances of your data items

evpozdniakov commented 3 years ago

@jquense thank you, make sense!