rsuite/rsuite

component values primitive or anything

cherepanov opened this issue · 2 comments

In rsuite where are three ways to pass values

  • primite
  • generic ItemDataType
  • eventKey/activeKey

Let's consider the Dropdown/Select components family.

Currently, ItemDataType and eventKey/activeKey can be anything, either primitive or object.

The documentation states that the value can only be a string, which is not accurate according to the implementation.

Comparison is made via shallowEqual, checking values only at the first level.

Is this the intended behavior in RSuite? If so, which components should also adhere to this?

Use case here to avoid data-mapping with complex shaped-objects and pass them as is.

Passing objects as values is common thing, most ui-kits handle this. Demo

Eventually i'd like to see it in RSuire as documented feature. If this is not intended implementation should be fixed.

SelectPicker
ItemDataType[]
value - indicated as string only

InputPicker
ItemDataType[]
value - indicated as string only

DropDown
activeKey/eventKey - indicated as sting only

Hi @cherepanov, we recommend using the string type for value and eventKey. For the sake of accessibility, the value of ItemDataType.value is set to the input element and ARIA attributes in some components. I will fix the definition of ItemDataType later.

Are there any plans to alter this behavior? I initially found that some code using this feature does not work with RSuite versions below 5.50, even though it was supposed to be a documented feature.