Skip to content

Commit

Permalink
Fixing the label for inputs when we received an invalid value
Browse files Browse the repository at this point in the history
  • Loading branch information
Topinaqui committed Aug 10, 2019
1 parent ff6d041 commit e4eb0e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/MdField/MdField.vue
Expand Up @@ -60,7 +60,8 @@
password: null,
togglePassword: false,
clear: false,
file: false
file: false,
hasInvalidValue: false
}
}),
provide () {
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/components/MdField/MdFieldMixin.js
Expand Up @@ -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();
})
}
}
Expand Down Expand Up @@ -95,6 +96,9 @@ export default {
}
}
},
isInvalidValue () {
return this.$el.validity.badInput
},
setFieldValue () {
this.MdField.value = this.model
},
Expand Down

0 comments on commit e4eb0e5

Please sign in to comment.