diff --git a/src/components/day/Day.js b/src/components/day/Day.js index 978b83d7f3..6c271bdf19 100644 --- a/src/components/day/Day.js +++ b/src/components/day/Day.js @@ -473,7 +473,9 @@ export default class DayComponent extends Field { DAY = null; } if (!this.showMonth) { - DAY = DAY === 0 ? 0 : DAY - 1; + if (!_.isNull(DAY)) { + DAY = DAY === 0 ? 0 : DAY - 1; + } YEAR = YEAR - 1; MONTH = null; } diff --git a/src/components/day/Day.unit.js b/src/components/day/Day.unit.js index f6d6114daa..159d5d547a 100644 --- a/src/components/day/Day.unit.js +++ b/src/components/day/Day.unit.js @@ -300,6 +300,18 @@ describe('Day Component', () => { comp1.fields.year.hide = false; }); + it('Should set correct default value if the day and month fields are hidden', (done) => { + comp1.defaultValue = '2024'; + comp1.fields.day.hide = true; + comp1.fields.month.hide = true; + Harness.testCreate(DayComponent, comp1).then((component) => { + assert.equal(component.data.date, '2024'); + done(); + }).catch(done); + comp1.fields.day.hide = false; + comp1.fields.month.hide = false; + }); + it('OnBlur validation should work properly with Day component', (done) => { const element = document.createElement('div');