Skip to content

Commit

Permalink
Merge 399a4e7 into 78287c9
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Sep 19, 2018
2 parents 78287c9 + 399a4e7 commit 9dbd0e6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/vaadin-date-picker-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,11 @@
this.__dispatchChange = true;
}
const inputValue = selectedDate && formatDate(Vaadin.DatePickerHelper._extractDateParts(selectedDate));
this.validate(inputValue);
this.value = this._formatISO(selectedDate);
const value = this._formatISO(selectedDate);
if (value !== this.value) {
this.validate(inputValue);
this.value = value;
}
this.__userInputOccurred = false;
this.__dispatchChange = false;
this._focusedDate = selectedDate;
Expand Down
24 changes: 24 additions & 0 deletions test/form-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
</template>
</test-fixture>

<test-fixture id="datepicker-required">
<template>
<vaadin-date-picker required></vaadin-date-picker>
</template>
</test-fixture>

<test-fixture id="datepicker-in-form">
<template>
<iron-form>
Expand Down Expand Up @@ -218,6 +224,24 @@
});
});

describe('required', () => {
let datepicker;

beforeEach(done => {
datepicker = fixture('datepicker-required');
setTimeout(done);
});

it('should not be invalid without user interactions', () => {
expect(datepicker.invalid).to.be.false;
});

it('should be invalid after validate() if value is not set', () => {
datepicker.validate();
expect(datepicker.invalid).to.be.true;
});
});

describe('using as a field in an iron-form', () => {
var datepicker, ironForm;

Expand Down

0 comments on commit 9dbd0e6

Please sign in to comment.