[Feature]: Add "selected option object" for Select widget
Is there an existing issue for this?
- [X] I have searched the existing issues
Summary
Hi! The Select widget only provides the selectedOptionValue and selectedOptionLabel which is good but we must also have selectedOption which is priceless in many cases.
Why should this be worked on?
The Select widget only provides the selectedOptionValue and selectedOptionLabel which is often not enough.
Context:
I have a Select input which makes server-side filtering on a graphql API. The server returns a list of users with their name, ID, and email address, plus some permissions/roles. When I select the user in the widget, I want to have all the data of the selected user, not only his ID (selectedOptionValue). Having only selectedOptionValue forces me to make another query or to write some complex javascript to get the information I already have. I can see that there's a prop called select.options that can contain any object not only {label, value}. It will be great to also have select.selectedOption.
Retool already supports that feature.
Thank you,
@GENL thank you for submitting this feature idea. To make it 100% clear, would you please share what the object should look like? Let's say:
selectedOptionLabel is AU and selectedOptionValue is Australia.
Meanwhile, are you able to unblock yourself? If not, you could try constructing the object in a JS function.
@rohan-arthur of course, there's a workaround with JS functions, but it makes the work harder.
If selectedOptionLabel is AU and selectedOptionValue is Australia then selectedOption should be:
{
area: 7688000,
continent: 'Australia',
flag: '🇦🇺',
label: 'AU',
lat: '...',
lon: '...',
name: 'Australia',
population: 25740000,
}