From 718d8a7636a69bc4626143bfde9bbccdf9076e81 Mon Sep 17 00:00:00 2001 From: Jacques Ikot Date: Thu, 4 Jul 2024 14:15:02 +0100 Subject: [PATCH 1/2] change value to label in onItemSelect inside SelectCell of table widget --- .../TableWidgetV2/component/cellComponents/SelectCell.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/src/widgets/TableWidgetV2/component/cellComponents/SelectCell.tsx b/app/client/src/widgets/TableWidgetV2/component/cellComponents/SelectCell.tsx index 89c9a1fe15ee..a0648a18a725 100644 --- a/app/client/src/widgets/TableWidgetV2/component/cellComponents/SelectCell.tsx +++ b/app/client/src/widgets/TableWidgetV2/component/cellComponents/SelectCell.tsx @@ -149,7 +149,7 @@ export const SelectCell = (props: SelectProps) => { const onSelect = useCallback( (option: DropdownOption) => { onItemSelect( - option.value || "", + option.label || "", rowIndex, alias, onOptionSelectActionString, From 330d0d3f82ea7a8769c350f7caa0714959838f12 Mon Sep 17 00:00:00 2001 From: Jacques Ikot Date: Mon, 8 Jul 2024 16:51:27 +0100 Subject: [PATCH 2/2] add test to check that on option select uses label instead of value in select cell --- .../TableV2/columnTypes/Select1_spec.ts | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts index ba126c6e70fe..000f373fe18b 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts @@ -174,7 +174,39 @@ describe( cy.discardTableRow(4, 0); }); - it("6. should check that currentRow is accessible in the select options", () => { + it("6. should check that on option select uses label as value in select cell (#34743)", () => { + cy.updateCodeInput( + ".t--property-control-options", + ` + [ + { + "label": "#1label", + "value": "#1value" + }, + { + "label": "#2label", + "value": "#2value" + }, + { + "label": "#3label", + "value": "#3value" + } + ] + `, + ); + cy.editTableSelectCell(0, 0); + cy.get(".menu-item-link").contains("#3label").click(); + + _.agHelper.ValidateToastMessage("#3label"); + + cy.get(".menu-virtual-list").should("not.exist"); + cy.readTableV2data(0, 0).then((val) => { + expect(val).to.equal("#3label"); + }); + cy.discardTableRow(4, 0); + }); + + it("7. should check that currentRow is accessible in the select options", () => { cy.updateCodeInput( ".t--property-control-options", ` @@ -199,7 +231,7 @@ describe( cy.get(".menu-item-text").contains("#1").should("not.exist"); }); - it("7. should check that 'same select option in new row' property is working", () => { + it("8. should check that 'same select option in new row' property is working", () => { _.propPane.NavigateBackToPropertyPane(); const checkSameOptionsInNewRowWhileEditing = () => { @@ -265,7 +297,7 @@ describe( checkSameOptionsWhileAddingNewRow(); }); - it("8. should check that 'new row select options' is working", () => { + it("9. should check that 'new row select options' is working", () => { const checkNewRowOptions = () => { // New row select options should be visible when "Same options in new row" is turned off _.propPane.TogglePropertyState("Same options in new row", "Off"); @@ -330,7 +362,7 @@ describe( checkNoOptionState(); }); - it("9. should check that server side filering is working", () => { + it("10. should check that server side filering is working", () => { _.dataSources.CreateDataSource("Postgres"); _.dataSources.CreateQueryAfterDSSaved( "SELECT * FROM public.astronauts {{this.params.filterText ? `WHERE name LIKE '%${this.params.filterText}%'` : ''}} LIMIT 10;",