mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-03-16 22:10:27 +00:00
clear input container state if model is falsy
This commit is contained in:
parent
aa3f95e036
commit
a8cc1602d9
4 changed files with 14 additions and 12 deletions
|
|
@ -7,9 +7,8 @@ export default {
|
|||
placeholder: String
|
||||
},
|
||||
watch: {
|
||||
value(value) {
|
||||
this.setParentValue(value);
|
||||
this.updateValues(value);
|
||||
value() {
|
||||
this.updateValues();
|
||||
},
|
||||
disabled() {
|
||||
this.setParentDisabled();
|
||||
|
|
@ -41,11 +40,13 @@ export default {
|
|||
setParentPlaceholder() {
|
||||
this.parentContainer.hasPlaceholder = !!this.placeholder;
|
||||
},
|
||||
updateValues(value) {
|
||||
const newValue = value || this.$el.value || this.value;
|
||||
updateValues() {
|
||||
this.$nextTick(() => {
|
||||
const newValue = this.$el.value || this.value;
|
||||
|
||||
this.setParentValue(newValue);
|
||||
this.parentContainer.inputLength = newValue ? newValue.length : 0;
|
||||
this.setParentValue(newValue);
|
||||
this.parentContainer.inputLength = newValue ? newValue.length : 0;
|
||||
});
|
||||
},
|
||||
onFocus() {
|
||||
if (this.parentContainer) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
throw new Error('You should wrap the md-input in a md-input-container');
|
||||
}
|
||||
|
||||
this.parentContainer.inputInstance = this;
|
||||
this.setParentDisabled();
|
||||
this.setParentRequired();
|
||||
this.setParentPlaceholder();
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
return {
|
||||
value: '',
|
||||
input: false,
|
||||
inputInstance: null,
|
||||
showPassword: false,
|
||||
enableCounter: false,
|
||||
hasSelect: false,
|
||||
|
|
@ -85,11 +86,9 @@
|
|||
}
|
||||
},
|
||||
clearInput() {
|
||||
if (this.isInput()) {
|
||||
this.input.value = '';
|
||||
this.setValue(this.input.value);
|
||||
this.$emit('input', this.input.value);
|
||||
}
|
||||
this.inputInstance.$el.value = '';
|
||||
this.inputInstance.$emit('input', '');
|
||||
this.setValue('');
|
||||
},
|
||||
setValue(value) {
|
||||
this.value = value;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
throw new Error('You should wrap the md-textarea in a md-input-container');
|
||||
}
|
||||
|
||||
this.parentContainer.inputInstance = this;
|
||||
this.setParentDisabled();
|
||||
this.setParentRequired();
|
||||
this.setParentPlaceholder();
|
||||
|
|
|
|||
Loading…
Reference in a new issue