Skip to content

Commit

Permalink
Fix #1429 close moving datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
jtommy committed May 26, 2019
1 parent 5cfc66d commit a55e305
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
38 changes: 26 additions & 12 deletions src/components/datepicker/Datepicker.vue
Expand Up @@ -21,8 +21,8 @@
:disabled="disabled"
:readonly="!editable"
v-bind="$attrs"
@click.native.stop="toggle(true)"
@keyup.native.enter="toggle(true)"
@click.native="onInputClick"
@keyup.native.enter="togglePicker(true)"
@change.native="onChange($event.target.value)"
@focus="handleOnFocus"
@blur="onBlur" />
Expand Down Expand Up @@ -113,7 +113,7 @@
:events="events"
:indicators="indicators"
:date-creator="dateCreator"
@close="toggle(false)"/>
@close="togglePicker(false)"/>
</div>

<footer
Expand Down Expand Up @@ -141,8 +141,6 @@
:readonly="false"
v-bind="$attrs"
@change.native="onChangeNativePicker"
@click.native.stop="toggle(true)"
@keyup.native.enter="toggle(true)"
@focus="handleOnFocus"
@blur="onBlur"/>
</div>
Expand Down Expand Up @@ -308,7 +306,7 @@
},
set(value) {
this.updateInternalState(value)
this.toggle(false)
this.togglePicker(false)
this.$emit('input', value)
}
},
Expand Down Expand Up @@ -361,7 +359,7 @@
*/
value(value) {
this.updateInternalState(value)
this.toggle(false)
this.togglePicker(false)
!this.isValid && this.$refs.input.checkHtml5Validity()
},
Expand Down Expand Up @@ -476,7 +474,7 @@
/*
* Toggle datepicker
*/
toggle(active) {
togglePicker(active) {
if (this.$refs.dropdown) {
this.$refs.dropdown.isActive = typeof active === 'boolean'
? active
Expand All @@ -487,10 +485,26 @@
/*
* Call default onFocus method and show datepicker
*/
handleOnFocus() {
this.onFocus()
handleOnFocus(event) {
this.onFocus(event)
if (this.openOnFocus) {
this.toggle(true)
this.togglePicker(true)
}
},
/*
* Toggle dropdown
*/
toggle() {
this.$refs.dropdown.toggle()
},
/*
* Avoid dropdown toggle when is already visible
*/
onInputClick(event) {
if (this.$refs.dropdown.isActive) {
event.stopPropagation()
}
},
Expand All @@ -500,7 +514,7 @@
keyPress(event) {
// Esc key
if (this.$refs.dropdown && this.$refs.dropdown.isActive && event.keyCode === 27) {
this.toggle(false)
this.togglePicker(false)
}
}
},
Expand Down
3 changes: 0 additions & 3 deletions src/components/timepicker/Timepicker.vue
Expand Up @@ -21,7 +21,6 @@
:readonly="!editable"
:rounded="rounded"
v-bind="$attrs"
@click.native.stop="toggle(true)"
@keyup.native.enter="toggle(true)"
@change.native="onChange($event.target.value)"
@focus="handleOnFocus"
Expand Down Expand Up @@ -94,8 +93,6 @@
:disabled="disabled"
:readonly="false"
v-bind="$attrs"
@click.native.stop="toggle(true)"
@keyup.native.enter="toggle(true)"
@change.native="onChange($event.target.value)"
@focus="handleOnFocus"
@blur="onBlur() && checkHtml5Validity()"/>
Expand Down

0 comments on commit a55e305

Please sign in to comment.