From 87848714559dba98b38419bfd50997abb0c153f1 Mon Sep 17 00:00:00 2001 From: lane-formio Date: Thu, 12 Sep 2024 09:53:13 -0500 Subject: [PATCH] Revert "FIO-8797: set empty day component value to the empty string" This reverts commit 65a1cfa15017c279ffc2a3ce59227726404a261f. --- src/WebformBuilder.unit.js | 2 +- src/components/day/Day.js | 7 ++++--- src/components/day/Day.unit.js | 11 ----------- test/renders/component-bootstrap-day-html-value0.html | 2 +- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/WebformBuilder.unit.js b/src/WebformBuilder.unit.js index 1d9d13c1ad..a86bacd704 100644 --- a/src/WebformBuilder.unit.js +++ b/src/WebformBuilder.unit.js @@ -216,7 +216,7 @@ describe('WebformBuilder tests', function() { done(); }, 200); }, 200); - }, 300); + }, 150); }).catch(done); }); diff --git a/src/components/day/Day.js b/src/components/day/Day.js index 4f51b6b2eb..add4bb960d 100644 --- a/src/components/day/Day.js +++ b/src/components/day/Day.js @@ -69,10 +69,11 @@ export default class DayComponent extends Field { /** * The empty value for day component. - * @returns {''} - The empty value of the day component. + * + * @return {'00/00/0000'} */ get emptyValue() { - return ''; + return '00/00/0000'; } get valueMask() { @@ -414,7 +415,7 @@ export default class DayComponent extends Field { setValueAt(index, value) { // temporary solution to avoid input reset // on invalid date. - if (value === 'Invalid date') { + if (!value || value === 'Invalid date') { return null; } const parts = value.split('/'); diff --git a/src/components/day/Day.unit.js b/src/components/day/Day.unit.js index fb65885e93..e83bfcb83b 100644 --- a/src/components/day/Day.unit.js +++ b/src/components/day/Day.unit.js @@ -22,17 +22,6 @@ describe('Day Component', () => { }); }); - it('Should handle blank data correctly', (done) => { - Harness.testCreate(DayComponent, comp1).then((component) => { - component.setValue(); - assert.equal(component.getValue(), ''); - component.checkValidity(); - assert.equal(component.errors.length, 0, 'Component should be valid with blank data'); - - done(); - }); - }); - it('Should change the max day when the month changes', (done) => { Harness.testCreate(DayComponent, comp1).then((component) => { Harness.testElements(component, 'option', 13); diff --git a/test/renders/component-bootstrap-day-html-value0.html b/test/renders/component-bootstrap-day-html-value0.html index 5acdda1bd7..0faf0b1d4b 100644 --- a/test/renders/component-bootstrap-day-html-value0.html +++ b/test/renders/component-bootstrap-day-html-value0.html @@ -2,6 +2,6 @@ -
-
+
00/00/0000
\ No newline at end of file