diff --git a/ui/src/components/form/inputBehaviors.tsx b/ui/src/components/form/inputBehaviors.tsx index 129dc40dd86936aff494a3b85c139e9f8149ac26..5171ec944dc0c52af343f702fcf18bf87a507b51 100644 --- a/ui/src/components/form/inputBehaviors.tsx +++ b/ui/src/components/form/inputBehaviors.tsx @@ -400,12 +400,15 @@ const InputBehaviorsEntityForm = ( const parseNewValue = (e: React.ChangeEvent) => { const target = e.target as HTMLInputElement; - if (target.value) { + // If the target is an input element, return its value + if (target.value !== undefined) { return target.value; } + // If the target is a checkbox or radio button, return its checked if ('checked' in target) { return target.checked; } + // If the target is neither an input element nor a checkbox/radio button, return null return null; }; diff --git a/ui/tests/e2e/page-data-form.cy.js b/ui/tests/e2e/page-data-form.cy.js index bb219d2ce0178d472ff4d1aa90ea69c27a93b570..7c63266b4a3a44e74cc2847b503a80cea1ca6c9e 100644 --- a/ui/tests/e2e/page-data-form.cy.js +++ b/ui/tests/e2e/page-data-form.cy.js @@ -31,7 +31,8 @@ describe('Page data form', () => { .findByLabelText('Title') .as('titleField'); cy.get('@titleField').focus(); - cy.get('@titleField').type('{selectall}This is a new title'); + cy.get('@titleField').clear(); + cy.get('@titleField').type('This is a new title'); cy.get('@titleField').should('have.value', 'This is a new title'); cy.get('button[aria-label="Undo"]').should('be.enabled'); cy.get('button[aria-label="Redo"]').should('be.disabled'); @@ -56,7 +57,8 @@ describe('Page data form', () => { .as('heroTitle'); cy.get('@heroTitle').should('have.value', 'hello, world!'); cy.get('@heroTitle').focus(); - cy.get('@heroTitle').type('{selectall}This is a new hero title'); + cy.get('@heroTitle').clear(); + cy.get('@heroTitle').type('This is a new hero title'); cy.wait('@patchPreview'); // Editing a component field should push that onto the undo state. cy.get('button[aria-label="Undo"]').should('be.enabled'); @@ -87,7 +89,9 @@ describe('Page data form', () => { .should('have.value', 'XB Needs This For The Time Being'); cy.get('@titleField').focus(); - cy.get('@titleField').type('{selectall}This is a new title'); + cy.get('@titleField').clear(); + cy.get('@titleField').should('have.value', ''); + cy.get('@titleField').type('This is a new title'); cy.get('@titleField').should('have.value', 'This is a new title'); cy.get('button[aria-label="Undo"]').should('be.enabled'); cy.get('button[aria-label="Redo"]').should('be.disabled');