From e4eb0e52169df59d31b055362399871796e9ccd1 Mon Sep 17 00:00:00 2001 From: Franklin Oliveira Date: Sat, 10 Aug 2019 09:34:19 -0300 Subject: [PATCH] Fixing the label for inputs when we received an invalid value --- src/components/MdField/MdField.vue | 5 +++-- src/components/MdField/MdFieldMixin.js | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/MdField/MdField.vue b/src/components/MdField/MdField.vue index 684e13b71..f4a3c0d01 100644 --- a/src/components/MdField/MdField.vue +++ b/src/components/MdField/MdField.vue @@ -60,7 +60,8 @@ password: null, togglePassword: false, clear: false, - file: false + file: false, + hasInvalidValue: false } }), provide () { @@ -79,7 +80,7 @@ return this.mdTogglePassword && this.MdField.password }, hasValue () { - return this.stringValue && this.stringValue.length > 0 + return (this.stringValue && this.stringValue.length > 0) || this.MdField.hasInvalidValue }, valueLength () { if (this.stringValue) { diff --git a/src/components/MdField/MdFieldMixin.js b/src/components/MdField/MdFieldMixin.js index 78815df94..f0fa0a77a 100644 --- a/src/components/MdField/MdFieldMixin.js +++ b/src/components/MdField/MdFieldMixin.js @@ -24,6 +24,7 @@ export default { if (value.constructor.toString().match(/function (\w*)/)[1].toLowerCase() !== 'inputevent') { this.$nextTick(() => { this.localValue = value + this.MdField.hasInvalidValue = this.isInvalidValue(); }) } } @@ -95,6 +96,9 @@ export default { } } }, + isInvalidValue () { + return this.$el.validity.badInput + }, setFieldValue () { this.MdField.value = this.model },