## 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 --> |
||
|---|---|---|
| .. | ||
| .husky | ||
| .yarn | ||
| cypress | ||
| docker/templates | ||
| generators | ||
| packages | ||
| public | ||
| src | ||
| test | ||
| typings | ||
| .babelrc | ||
| .dockerignore | ||
| .editorconfig | ||
| .eslintrc.base.json | ||
| .eslintrc.js | ||
| .fork-ts-checkerrc | ||
| .gitignore | ||
| .lintstagedrc.json | ||
| .nvmrc | ||
| .prettierignore | ||
| .prettierrc | ||
| .sentryclirc | ||
| .yarnrc.yml | ||
| build.sh | ||
| craco.build.config.js | ||
| craco.common.config.js | ||
| craco.dev.config.js | ||
| cypress_ci_custom.config.ts | ||
| cypress_ci_hosted.config.ts | ||
| cypress_ci.config.ts | ||
| cypress-add-tags.js | ||
| cypress.config.ts | ||
| download-assets.js | ||
| jest.config.js | ||
| package.json | ||
| README.md | ||
| README.old.md | ||
| start-caddy.sh | ||
| start-https.sh | ||
| tailwind.config.js | ||
| tsconfig.json | ||
| tsconfig.path.json | ||
| vercel.json | ||
| yarn.lock | ||
Appsmith Client
This project was bootstrapped with Create React App.
For details on setting up your development machine, please refer to the Setup Guide