Skip to content

Commit

Permalink
fix: validate date-time-picker when required is set to false (#7908) (#…
Browse files Browse the repository at this point in the history
…7914)

Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
  • Loading branch information
vaadin-bot and web-padawan authored Oct 2, 2024
1 parent 82a81c7 commit 1670f57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/date-time-picker/src/vaadin-date-time-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,12 @@ class DateTimePicker extends FieldMixin(DisabledMixin(FocusMixin(ThemableMixin(E
if (timePicker) {
timePicker.required = required;
}

if (this.__oldRequired && !required) {
this.validate();
}

this.__oldRequired = required;
}

/** @private */
Expand Down
5 changes: 5 additions & 0 deletions packages/date-time-picker/test/validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ const fixtures = {
dateTimePicker.validate();
expect(dateTimePicker.invalid).to.be.true;
});

it('should validate when setting required to false', () => {
dateTimePicker.required = false;
expect(validateSpy).to.be.calledOnce;
});
});

describe('document losing focus', () => {
Expand Down

0 comments on commit 1670f57

Please sign in to comment.