Skip to content

Commit

Permalink
feat: hide the date picker when click outside
Browse files Browse the repository at this point in the history
  • Loading branch information
abdelrazzaq-dev committed Jan 16, 2020
1 parent b600e55 commit 830bb1b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/AppDateInput.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="pug">
.c-date-picker
.c-date-picker(v-click-outside="hide")
label.c-date-picker__label(
v-if="label"
:for="name"
Expand All @@ -8,7 +8,7 @@
)
.c-date-picker__container
input.c-date-picker__field(
@focus="showPicker = !showPicker"
@focus="showPicker = true"
v-model="localeDate"
v-bind='$attrs'
type="text"
Expand All @@ -28,13 +28,17 @@

<script lang="ts">
import { Vue, Component, Prop } from "vue-property-decorator";
import ClickOutside from "vue-click-outside";
import DatePicker from "./DatePicker.vue";
import { ILocaleOption } from "../util/helpers";
@Component({
name: "app-date-input",
components: {
DatePicker
},
directives: {
ClickOutside
}
})
export default class AppDateInput extends Vue {
Expand All @@ -51,5 +55,9 @@ export default class AppDateInput extends Vue {
year: "numeric",
day: "numeric"
});
hide() {
this.showPicker = false;
}
}
</script>

0 comments on commit 830bb1b

Please sign in to comment.