From c86ee801660aecd30b44c4721b62b3c34dc036ea Mon Sep 17 00:00:00 2001 From: Nar Cuenca Date: Mon, 19 Feb 2024 13:19:23 +0800 Subject: [PATCH 1/2] fix: prevent unselecting value --- .../src/app/components/Editor/Field/Field.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/apps/content-editor/src/app/components/Editor/Field/Field.tsx b/src/apps/content-editor/src/app/components/Editor/Field/Field.tsx index 489555f4ec..1c291fb3c6 100644 --- a/src/apps/content-editor/src/app/components/Editor/Field/Field.tsx +++ b/src/apps/content-editor/src/app/components/Editor/Field/Field.tsx @@ -545,7 +545,11 @@ export const Field = ({ size="small" value={value} exclusive - onChange={(_, val) => onChange(val, name)} + onChange={(_, val) => { + if (val !== null) { + onChange(val, name); + } + }} > Date: Mon, 19 Feb 2024 13:33:12 +0800 Subject: [PATCH 2/2] task: update tests --- cypress/e2e/content/content.spec.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/cypress/e2e/content/content.spec.js b/cypress/e2e/content/content.spec.js index 774d0cc93f..d6ed2be946 100644 --- a/cypress/e2e/content/content.spec.js +++ b/cypress/e2e/content/content.spec.js @@ -150,17 +150,6 @@ describe("Content Specs", () => { .contains("Yes") .should("have.class", "Mui-selected"); - // Click the "Yes" button again to deselect it - cy.get("#12-575f7c-trw1w3 button").contains("Yes").click(); - - // Check if neither "Yes" nor "No" buttons have the ".Mui-selected" class - cy.get("#12-575f7c-trw1w3 button") - .contains("Yes") - .should("not.have.class", "Mui-selected"); - cy.get("#12-575f7c-trw1w3 button") - .contains("No") - .should("not.have.class", "Mui-selected"); - // Click the "No" button to select it cy.get("#12-575f7c-trw1w3 button").contains("No").click(); @@ -168,8 +157,10 @@ describe("Content Specs", () => { cy.get("#12-575f7c-trw1w3 button") .contains("No") .should("have.class", "Mui-selected"); + }); - // Click the "No" button again to deselect it + it("Yes/No Field: Does not allow user to deselect value", () => { + // Click the "No" button to deselect it cy.get("#12-575f7c-trw1w3 button").contains("No").click(); // Check again if neither "Yes" nor "No" buttons have the ".Mui-selected" class @@ -178,7 +169,7 @@ describe("Content Specs", () => { .should("not.have.class", "Mui-selected"); cy.get("#12-575f7c-trw1w3 button") .contains("No") - .should("not.have.class", "Mui-selected"); + .should("have.class", "Mui-selected"); }); // TODO: Need to confirm toggling of value