diff --git a/packages/date-time-picker/src/vaadin-date-time-picker.js b/packages/date-time-picker/src/vaadin-date-time-picker.js index 9fff9adfb3..f0805914c7 100644 --- a/packages/date-time-picker/src/vaadin-date-time-picker.js +++ b/packages/date-time-picker/src/vaadin-date-time-picker.js @@ -724,6 +724,12 @@ class DateTimePicker extends FieldMixin(DisabledMixin(FocusMixin(ThemableMixin(E if (timePicker) { timePicker.required = required; } + + if (this.__oldRequired && !required) { + this.validate(); + } + + this.__oldRequired = required; } /** @private */ diff --git a/packages/date-time-picker/test/validation.test.js b/packages/date-time-picker/test/validation.test.js index ffca0be55f..28e81e18b4 100644 --- a/packages/date-time-picker/test/validation.test.js +++ b/packages/date-time-picker/test/validation.test.js @@ -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', () => {