-
Notifications
You must be signed in to change notification settings - Fork 842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiComboBox] Allow any objects as options #1456
Comments
The request totally makes sense, but I'd be hesitant to make that change in the existing component itself - either it's a breaking change, or we look for some specific object key's presence and switch behaviour based on that, adding quite a bit of complexity. As an easier way around, I'd recommend during the mapping of Object -> Option to create a |
I really like this idea! Could we make this change BWC by assuming that |
@cjcenizal That's kind of what I was thinking, we could just default the |
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment. |
I'd like to add this as part of the #2841 issue. |
Due to the age of the request and lack of other requests, we're closing this issue as not planned by the EUI team. That being said, we'll welcome a PR if anyone feels strongly about contributing or having this functionality in EUI. |
EuiComboBox currently expects a list of
options
in the following format:When the
onChange
event fires, it gives you back theselectedOptions
in the same format.As a result, any place that the EuiComboBox is used with a list of some complex object, there needs to be a wrapping/unwrapping that takes place. First, the objects (and selected objects) need to be mapped to the format above. Then, in the
onChange
, they need to be mapped back to the original object.For example, say I have a list of index patterns for which I'd like to display a combo box. In order to create the
options
, I need to map over the list and create an object like{ label: indexPattern.title }
. Then, in theonChange
, I need to map over theselectedOptions
and retrieve the originalindexPattern
by matching thetitle
to the optionlabel
.I would propose, instead of expecting the options in this format, we could pass the
options
in as the original objects. Then, we'd add agetOptionLabel
andgetOptionColor
, etc. that would be invoked to get the actual label or color to display in the component. Then, in theonChange
, you could pass the selected options back in their original format. This would eliminate a lot of the boilerplate code associated with the EuiComboBox.Thoughts?
The text was updated successfully, but these errors were encountered: