Skip to content

Commit

Permalink
FIO-8986 fixed setting default value for day ,component with hidden d…
Browse files Browse the repository at this point in the history
…ay and month
  • Loading branch information
HannaKurban authored and lane-formio committed Sep 19, 2024
1 parent 77a76dd commit 4db6d1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/day/Day.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions src/components/day/Day.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit 4db6d1e

Please sign in to comment.