Skip to content
Snippets Groups Projects
Commit ba3c8207 authored by Parth Bhattacharya's avatar Parth Bhattacharya Committed by Lauri Timmanee
Browse files

Issue #3498485 by jessebaker, parthbcharya, lauriii, callumharrod, bnjmnm:...

Issue #3498485 by jessebaker, parthbcharya, lauriii, callumharrod, bnjmnm: 'false' appears in Page Title when deleting all characters
parent 3dadf5ff
Branches
Tags
1 merge request!661issue-3498485: fixed false appearing in input text fields
Pipeline #424688 passed with warnings
......@@ -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;
};
......
......@@ -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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment