vue-datetime icon indicating copy to clipboard operation
vue-datetime copied to clipboard

Datetime component fires this.emitInput() upon creation - Solved

Open aqjw opened this issue 4 years ago • 0 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Fixed issue https://github.com/mariomka/vue-datetime/issues/46

Here is the diff that solved my problem:

diff --git a/node_modules/vue-datetime/src/Datetime.vue b/node_modules/vue-datetime/src/Datetime.vue
index a8d9e99..4c28881 100644
--- a/node_modules/vue-datetime/src/Datetime.vue
+++ b/node_modules/vue-datetime/src/Datetime.vue
@@ -206,7 +206,8 @@ export default {
         datetime = startOfDay(datetime)
       }
 
-      this.$emit('input', datetime ? datetime.toISO() : '')
+      const value = datetime ? datetime.toISO() : null
+      this.datetime !== value ? this.$emit('input', value) : null
     },
     open (event) {
       event.target.blur()

aqjw avatar Oct 23 '21 21:10 aqjw