Skip to content

Commit

Permalink
Close the datepicker on unfocus (#591)
Browse files Browse the repository at this point in the history
Close the datepicker on unfocus
  • Loading branch information
skjnldsv committed Sep 13, 2019
2 parents 2ef4b42 + 4c36a4e commit 563f576
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/components/ActionInput/ActionInput.vue
Expand Up @@ -38,7 +38,7 @@ All undocumented attributes will be bound to the input or the datepicker. e.g. `
<template>
<li :class="{ 'action--disabled': disabled }">
<span :class="{ 'action-input--picker': isDatePickerType , 'action-input-picker--disabled': disabled}"
class="action-input">
class="action-input" @mouseleave="onLeave">
<!-- icon -->
<span :class="[isIconUrl ? 'action-input__icon--url' : icon]"
:style="{ backgroundImage: isIconUrl ? `url(${icon})` : null }"
Expand All @@ -49,11 +49,11 @@ All undocumented attributes will be bound to the input or the datepicker. e.g. `
:disabled="disabled" @submit.prevent="onSubmit">

<DatetimePicker v-if="isDatePickerType"
:value="value" :placeholder="text"
:disabled="disabled" :type="isDatePickerType"
ref="datetimepicker" :value="value"
:placeholder="text" :disabled="disabled"
:type="isDatePickerType"
:input-class="['mx-input', { focusable: isFocusable }]"
class="action-input__picker"
v-bind="$attrs"
class="action-input__picker" v-bind="$attrs"
@input="onInput" @change="onChange" />

<template v-else>
Expand Down Expand Up @@ -161,6 +161,12 @@ export default {
},
methods: {
// closing datepicker popup on mouseleave = unfocus
onLeave() {
if (this.$refs.datetimepicker && this.$refs.datetimepicker.$refs.datepicker) {
this.$refs.datetimepicker.$refs.datepicker.closePopup()
}
},
onInput(event) {
/**
* Emitted on input events of the text field
Expand Down

0 comments on commit 563f576

Please sign in to comment.