File tree Expand file tree Collapse file tree 4 files changed +14
-12
lines changed
src/components/mdInputContainer Expand file tree Collapse file tree 4 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,8 @@ export default {
7
7
placeholder : String
8
8
} ,
9
9
watch : {
10
- value ( value ) {
11
- this . setParentValue ( value ) ;
12
- this . updateValues ( value ) ;
10
+ value ( ) {
11
+ this . updateValues ( ) ;
13
12
} ,
14
13
disabled ( ) {
15
14
this . setParentDisabled ( ) ;
@@ -41,11 +40,13 @@ export default {
41
40
setParentPlaceholder ( ) {
42
41
this . parentContainer . hasPlaceholder = ! ! this . placeholder ;
43
42
} ,
44
- updateValues ( value ) {
45
- const newValue = value || this . $el . value || this . value ;
43
+ updateValues ( ) {
44
+ this . $nextTick ( ( ) => {
45
+ const newValue = this . $el . value || this . value ;
46
46
47
- this . setParentValue ( newValue ) ;
48
- this . parentContainer . inputLength = newValue ? newValue . length : 0 ;
47
+ this . setParentValue ( newValue ) ;
48
+ this . parentContainer . inputLength = newValue ? newValue . length : 0 ;
49
+ } ) ;
49
50
} ,
50
51
onFocus ( ) {
51
52
if ( this . parentContainer ) {
Original file line number Diff line number Diff line change 37
37
throw new Error (' You should wrap the md-input in a md-input-container' );
38
38
}
39
39
40
+ this .parentContainer .inputInstance = this ;
40
41
this .setParentDisabled ();
41
42
this .setParentRequired ();
42
43
this .setParentPlaceholder ();
Original file line number Diff line number Diff line change 32
32
return {
33
33
value: ' ' ,
34
34
input: false ,
35
+ inputInstance: null ,
35
36
showPassword: false ,
36
37
enableCounter: false ,
37
38
hasSelect: false ,
85
86
}
86
87
},
87
88
clearInput () {
88
- if (this .isInput ()) {
89
- this .input .value = ' ' ;
90
- this .setValue (this .input .value );
91
- this .$emit (' input' , this .input .value );
92
- }
89
+ this .inputInstance .$el .value = ' ' ;
90
+ this .inputInstance .$emit (' input' , ' ' );
91
+ this .setValue (' ' );
93
92
},
94
93
setValue (value ) {
95
94
this .value = value;
Original file line number Diff line number Diff line change 36
36
throw new Error (' You should wrap the md-textarea in a md-input-container' );
37
37
}
38
38
39
+ this .parentContainer .inputInstance = this ;
39
40
this .setParentDisabled ();
40
41
this .setParentRequired ();
41
42
this .setParentPlaceholder ();
You can’t perform that action at this time.
0 commit comments