appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.35k stars 3.72k forks source link

[Feature]: Add "selected option object" for Select widget #18143

Open GENL opened 1 year ago

GENL commented 1 year ago

Is there an existing issue for this?

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,

rohan-arthur commented 1 year ago

@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.

GENL commented 1 year ago

@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,
}