You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the Select component '@blueprintjs/select' and use an array of objects for the items prop.
Specify the activeItem prop as one of the objects in the items prop
Provide a value prop.
Actual behavior
The activeItem is not highlighted when the select's popover opens showing the list of items
Expected behavior
activeItem should be highlighter
Possible solution
The activeItem prop works as expected when the list of items are of type 'string'. I believe this part of the source code is what's setting the itemRenderer modifiers:
@jonavila the === check will definitely fail if the two objects are not exactly the same object. not objects that look the same but actually the same. this is a known limitation of the API. to fix it we'll have to introduce an itemComparator prop a la itemDisabled to allow customizing the equality check. see #1340.
example:
// actually the same instanceconstobj={prop: "yes"};constobj2=obj;obj===obj2// true// look the same, separate instancesconsta={a: 5};constb={a: 5};a===b// false
Environment
Steps to reproduce
items
prop.activeItem
prop as one of the objects in theitems
propvalue
prop.Actual behavior
The activeItem is not highlighted when the select's popover opens showing the list of items
Expected behavior
activeItem should be highlighter
Possible solution
The
activeItem
prop works as expected when the list ofitems
are of type 'string'. I believe this part of the source code is what's setting theitemRenderer
modifiers:https://github.com/palantir/blueprint/blob/develop/packages/select/src/components/query-list/queryList.tsx#L211
My guess is the equality of activeItem === item is failing for objects
The text was updated successfully, but these errors were encountered: