Skip to content

Commit 7e03465

Browse files
fix: check for bad input when updating _hasInputValue (#620)
Co-authored-by: Sergey Vinogradov <[email protected]>
1 parent 8fd245f commit 7e03465

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/vaadin-number-field.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,21 @@
418418

419419
return super.checkValidity();
420420
}
421+
422+
/**
423+
* Native [type=number] inputs don't update their value
424+
* when you are entering input that the browser is unable to parse
425+
* e.g. "--5", hence we have to override this method from `InputMixin`
426+
* so that, when value is empty, it would additionally check
427+
* for bad input based on the native `validity.badInput` property.
428+
*
429+
* @param {InputEvent} event
430+
* @protected
431+
* @override
432+
*/
433+
_setHasInputValue(event) {
434+
this._hasInputValue = event.target.value.length > 0 || event.target.validity.badInput;
435+
}
421436
}
422437

423438
window.customElements.define(NumberFieldElement.is, NumberFieldElement);

0 commit comments

Comments
 (0)