Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/MdDatepicker/MdDatepicker.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<md-field :class="['md-datepicker', { 'md-native': !this.mdOverrideNative }]" md-clearable>
<md-field :class="['md-datepicker', { 'md-native': !this.mdOverrideNative }]" :md-clearable="mdClearable" @md-clear="onClear">
Copy link
Contributor

@saxxi saxxi Jan 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

<md-field
  :class="['md-datepicker', { 'md-native': !this.mdOverrideNative }]"
  v-bind="$props"
  v-on="listeners">

You can add a computed

    computed: {
      listeners () {
        return {
          ...this.$listeners,
          // here you can add override listeners
        }
      },
    },

Then let the caller decide to add a md-clearable:

<md-datepicker md-clearable ... >
  <label>Date</label>
</md-datepicker>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for this solution!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current way is fine, to stay consistent with the existing api

<md-date-icon class="md-date-icon" @click.native="toggleDialog" />
<md-input :type="type" ref="input" v-model="inputDate" @focus.native="onFocus" :pattern="pattern" />

Expand Down Expand Up @@ -65,6 +65,10 @@
MdDebounce: {
type: Number,
default: 1000
},
mdClearable: {
type: Boolean,
default: true
}
},
data: () => ({
Expand Down Expand Up @@ -221,6 +225,9 @@
} else {
Vue.util.warn(`The datepicker value is not a valid date. Given value: ${this.value}`)
}
},
onClear() {
this.$emit('md-clear')
}
},
created () {
Expand Down