Skip to content

Commit

Permalink
Fixing the label for inputs when we received an invalid value (#2108)
Browse files Browse the repository at this point in the history
Co-authored-by: Beniamin Marcu <[email protected]>
  • Loading branch information
Topinaqui and marqbeniamin authored Aug 13, 2020
1 parent 5453944 commit 7941614
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 @@ -112,6 +113,9 @@ export default {
onParentFormReset () {
this.clearField()
},
isInvalidValue () {
return this.$el.validity.badInput
},
setFieldValue () {
this.MdField.value = this.model
},
Expand Down

0 comments on commit 7941614

Please sign in to comment.