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 11<template >
22 <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 " >
44 {{ floatLabel }}
5- </div >
5+ </label >
66 <slot ></slot >
77 </div >
88</template >
@@ -22,11 +22,16 @@ export default {
2222 dispatch: {
2323 type: Boolean ,
2424 default: true
25+ },
26+ for: {
27+ type: String ,
28+ default: null
2529 }
2630 },
2731 data () {
2832 return {
2933 formEl: undefined ,
34+ labelEl: undefined ,
3035 isActive: false ,
3136 isFocused: false
3237 }
@@ -37,6 +42,12 @@ export default {
3742 this .formEl .addEventListener (' input' , this .updateIsFocused )
3843 this .formEl .addEventListener (' blur' , this .updateIsFocused )
3944 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+
4051 this .dispatchInput ()
4152 },
4253 beforeDestroy () {
@@ -64,6 +75,9 @@ export default {
6475 }
6576 },
6677 computed: {
78+ inputId () {
79+ return this .for
80+ },
6781 classObject () {
6882 return {
6983 ' vfl-label-on-input' : this .on && this .isActive ,
You can’t perform that action at this time.
0 commit comments