PromucFlow_constructor/app/client/src
Jacques Ikot 9f387d5763
fix: Correct Select Widget Mapping for Dynamic Label and Value Keys (#35862)
## Description
**Problem**
When the Select widget's labelKey or valueKey properties are switched to
JS mode, passing a function that returns a string as the key causes the
dropdown options to break. Instead of correctly mapping the labels and
values, the options are incorrectly returned as an array of the key
itself.

**Root Cause**
The issue lies in the `getOptions` function in derived.js. The logic
that computes the select options based on the labelKey and valueKey was
not handling cases where these properties are functions that return
arrays. Instead of mapping through the source data and returning the
corresponding values for each key, the function was mistakenly returning
the entire array.

**Solution**
The `getOptions` function in derived.js has been updated to correctly
handle cases where labelKey or valueKey are arrays. The function now
maps through the sourceData and computes the correct labels and values
based on the provided properties, ensuring that the dropdown options are
displayed as expected.



Fixes #35269

## Automation

/ok-to-test tags="@tag.Sanity, @tag.Select, @tag.Widget, @tag.Binding"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/10560970428>
> Commit: 118badee07c47fe72f727f8ab248c29685f6f7a1
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10560970428&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.Select, @tag.Widget, @tag.Binding`
> Spec:
> <hr>Mon, 26 Aug 2024 15:24:26 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **New Features**
- Enhanced test coverage for the Select widget by adding new test cases
to validate the correct functioning of JavaScript functions in the label
and value keys.
- Improved processing of `optionLabel` and `optionValue` properties for
the Select widget, ensuring accurate mapping to `sourceData`.
- Introduced a new helper function to streamline the validation of label
and value keys in the Select widget tests.

- **Bug Fixes**
- Corrected the handling of multiple options in the Select widget to
enhance data mapping accuracy and functionality.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-08-27 07:54:44 +01:00
..
actions chore: Cleanup Redux Actions file (#35720) 2024-08-22 09:49:30 +05:30
api chore: Cleanup Redux Actions file (#35720) 2024-08-22 09:49:30 +05:30
assets chore: Remove google fonts imported from googleapis (#35392) 2024-08-07 08:49:04 +05:30
ce chore: Revert "fix: Add mode property to forkApplicationSaga" (#35873) 2024-08-26 16:30:00 +08:00
components feat: Action redesign: Updating Mongo plugin form config (#35883) 2024-08-27 09:27:03 +05:30
constants chore: use ads icons (#35633) 2024-08-16 17:23:57 +03:00
ee chore: rename old ADS package (#35517) 2024-08-08 15:55:00 +03:00
enterprise fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
entities chore: Cleanup Redux Actions file (#35720) 2024-08-22 09:49:30 +05:30
globalStyles fix: Sync EE items into CE (#34373) 2024-06-24 09:36:38 +00:00
icons chore: rename ADS package (#35583) 2024-08-09 17:20:29 +03:00
IDE chore: rename ADS package (#35583) 2024-08-09 17:20:29 +03:00
layoutSystems chore: move anvil widgets to wds (#35812) 2024-08-22 20:18:20 +02:00
mockComponentProps
mockResponses
mocks fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
navigation fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
pages chore: Input morphing (#35845) 2024-08-27 12:15:45 +05:30
plugins/Linting fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
polyfills chore: enable no-explicit-any rule (#35321) 2024-07-31 18:41:28 +03:00
reducers chore: Revert "fix: Add mode property to forkApplicationSaga" (#35873) 2024-08-26 16:30:00 +08:00
reflow chore: enable no-explicit-any rule (#35321) 2024-07-31 18:41:28 +03:00
sagas chore: Cleanup Redux Actions file (#35720) 2024-08-22 09:49:30 +05:30
selectors chore: Input morphing (#35845) 2024-08-27 12:15:45 +05:30
templates
theme
transformers fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
UITelemetry chore: filter smartlook urls from tracing assets in page load instrumentation (#35738) 2024-08-19 11:39:39 +05:30
usagePulse fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
utils chore: Cleanup Redux Actions file (#35720) 2024-08-22 09:49:30 +05:30
WidgetProvider chore: Input morphing (#35845) 2024-08-27 12:15:45 +05:30
WidgetQueryGenerators chore: enable no-explicit-any rule (#35321) 2024-07-31 18:41:28 +03:00
widgets fix: Correct Select Widget Mapping for Dynamic Label and Value Keys (#35862) 2024-08-27 07:54:44 +01:00
workers fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
App.css
AppErrorBoundry.tsx chore: rename ADS package (#35583) 2024-08-09 17:20:29 +03:00
config.d.ts fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
Globals.d.ts fix: Sync EE items into CE (#34373) 2024-06-24 09:36:38 +00:00
index.css chore: Remove google fonts imported from googleapis (#35392) 2024-08-07 08:49:04 +05:30
index.tsx chore: rename ADS package (#35583) 2024-08-09 17:20:29 +03:00
LandingScreen.tsx fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
preload-route-chunks.ts fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
react-app-env.d.ts
RouteChangeListener.tsx chore: added route listener on non-trackable URLs (#25671) 2023-08-11 17:04:42 +05:30
serviceWorker.ts chore: Remove some logs and errors from console - 1/n (#35674) 2024-08-18 14:48:08 +05:30
store.ts fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
wdyr.ts chore: improve eslint rules (#26056) 2023-08-07 15:38:48 +03:00