PromucFlow_constructor/app/client
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
..
.husky ci: Add pre push hook to not allow ee changes in ce (#35276) 2024-07-30 12:11:27 +05:30
.yarn
cypress fix: Correct Select Widget Mapping for Dynamic Label and Value Keys (#35862) 2024-08-27 07:54:44 +01:00
docker/templates
generators
packages chore: Input morphing (#35845) 2024-08-27 12:15:45 +05:30
public chore: Upgrade TinyMCE (#35399) 2024-08-08 20:08:09 +05:30
src fix: Correct Select Widget Mapping for Dynamic Label and Value Keys (#35862) 2024-08-27 07:54:44 +01:00
test chore: Cleanup Redux Actions file (#35720) 2024-08-22 09:49:30 +05:30
typings
.babelrc chore: rename old ADS package (#35517) 2024-08-08 15:55:00 +03:00
.dockerignore
.editorconfig
.eslintrc.base.json chore: adding eslint rules to warn new object and function props (#35757) 2024-08-24 13:28:34 +05:30
.eslintrc.js fix: change appsmith alias (#35349) 2024-08-06 17:52:22 +03:00
.fork-ts-checkerrc
.gitignore
.lintstagedrc.json
.nvmrc
.prettierignore
.prettierrc
.sentryclirc
.yarnrc.yml
build.sh chore: reverted client profiled build (#35306) 2024-07-31 15:23:08 +05:30
craco.build.config.js chore: Prefetch module apis in service worker (#34003) 2024-06-14 16:30:23 +05:30
craco.common.config.js
craco.dev.config.js chore: Prefetch module apis in service worker (#34003) 2024-06-14 16:30:23 +05:30
cypress_ci_custom.config.ts test: removed retries from all config files (#35750) 2024-08-20 11:20:35 +05:30
cypress_ci_hosted.config.ts test: removed retries from all config files (#35750) 2024-08-20 11:20:35 +05:30
cypress_ci.config.ts test: removed retries from all config files (#35750) 2024-08-20 11:20:35 +05:30
cypress-add-tags.js
cypress.config.ts test: removed retries from config file (#35284) 2024-08-16 19:01:28 +05:30
download-assets.js
jest.config.js chore: Rename wds packages (#35686) 2024-08-16 11:19:42 +05:30
package.json chore: adding eslint rules to warn new object and function props (#35757) 2024-08-24 13:28:34 +05:30
README.md
README.old.md
start-caddy.sh chore: Remove deprecated start-https.sh message (#33856) 2024-05-31 07:18:57 +05:30
start-https.sh chore: Remove deprecated start-https.sh message (#33856) 2024-05-31 07:18:57 +05:30
tailwind.config.js
tsconfig.json chore: upgrade typescript to 5.4 (#35181) 2024-07-30 16:15:48 +02:00
tsconfig.path.json chore: rename old ADS package (#35517) 2024-08-08 15:55:00 +03:00
vercel.json
yarn.lock chore: adding eslint rules to warn new object and function props (#35757) 2024-08-24 13:28:34 +05:30

Appsmith Client

This project was bootstrapped with Create React App.

For details on setting up your development machine, please refer to the Setup Guide