This repository was archived by the owner on Apr 25, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" vfl-has-label" >
3
- <div class =" vfl-label" :class =" classObject" :style =" { width }" @click = " focusFormEl " >
3
+ <label class =" vfl-label" :class =" classObject" :style =" { width }" :for = " inputId " >
4
4
{{ floatLabel }}
5
- </div >
5
+ </label >
6
6
<slot ></slot >
7
7
</div >
8
8
</template >
@@ -22,11 +22,16 @@ export default {
22
22
dispatch: {
23
23
type: Boolean ,
24
24
default: true
25
+ },
26
+ for: {
27
+ type: String ,
28
+ default: null
25
29
}
26
30
},
27
31
data () {
28
32
return {
29
33
formEl: undefined ,
34
+ labelEl: undefined ,
30
35
isActive: false ,
31
36
isFocused: false
32
37
}
@@ -37,6 +42,12 @@ export default {
37
42
this .formEl .addEventListener (' input' , this .updateIsFocused )
38
43
this .formEl .addEventListener (' blur' , this .updateIsFocused )
39
44
this .formEl .addEventListener (' focus' , this .updateIsFocused )
45
+
46
+ if (! this .for ) {
47
+ this .labelEl = this .$el .querySelector (' label' )
48
+ this .labelEl .addEventListener (' click' , this .focusFormEl )
49
+ }
50
+
40
51
this .dispatchInput ()
41
52
},
42
53
beforeDestroy () {
@@ -64,6 +75,9 @@ export default {
64
75
}
65
76
},
66
77
computed: {
78
+ inputId () {
79
+ return this .for
80
+ },
67
81
classObject () {
68
82
return {
69
83
' vfl-label-on-input' : this .on && this .isActive ,
You can’t perform that action at this time.
0 commit comments