Skip to content

Commit

Permalink
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/vaadin-text-field-mixin.html
Original file line number Diff line number Diff line change
@@ -572,7 +572,9 @@
* @returns {boolean}
*/
checkValidity() {
if (this.required || this.pattern || this.maxlength || this.minlength) {
// Note (Yuriy): `__forceCheckValidity` is used in containing components (i.e. `vaadin-date-picker`) in order
// to force the checkValidity instead of returning the previous invalid state.
if (this.required || this.pattern || this.maxlength || this.minlength || this.__forceCheckValidity) {
return this.inputElement.checkValidity();
} else {
return !this.invalid;
9 changes: 9 additions & 0 deletions test/validation.html
Original file line number Diff line number Diff line change
@@ -200,6 +200,15 @@
expect(tf.invalid).to.be.true;
});

it('should force check and change invalid property if `__forceCheckValidity` is set', function() {
tf.validate();
expect(tf.invalid).to.be.false;
tf.invalid = true;
tf.__forceCheckValidity = true;
tf.validate();
expect(tf.invalid).to.be.false;
});

it('should override explicitly set invalid if constraints are set', function() {
tf.invalid = true;
tf.value = 'foo';

0 comments on commit 8edd5fd

Please sign in to comment.