MikaelEdebro / vue-airbnb-style-datepicker

A VueJs datepicker with a similar look and functionality as the popular AirBnb datepicker.
https://mikaeledebro.gitbooks.io/vue-airbnb-style-datepicker/
MIT License
505 stars 105 forks source link

Datepicker form field automatically clears when I try to print #134

Open blerg-rush opened 4 years ago

blerg-rush commented 4 years ago

Expected behavior:

Datepicker retains its value until I change it or reload the page

Actual behavior:

When a print dialog opens and closes, the value of the field is set to ""

Environment

Source

<!-- Vue component template -->

<div class="datepicker-trigger">
  <b-form-group
    label="Issue Date"
    label-for="issue-date"
    class="small-label"
  >
    <b-form-input
      id="datepicker-trigger"
      placeholder="Select date"
      :value="toDateString(issueDate)"
      required
    />
    <AirbnbStyleDatepicker
      class="overlay"
      :trigger-element-id="'datepicker-trigger'"
      :mode="'single'"
      :fullscreen-mobile="true"
      :date="issueDate"
      :key="1"
      @date-one-selected="val => { issueDate = val }"
    />
  </b-form-group>
</div>
// Vue component script

computed: {
  issueDate: {
    get () {
      return this.$store.state.invoice.issueDate
    },
    set (value) {
      this.$store.commit('updateInvoiceIssueDate', value)
    }
  }
}
// Vuex store

state {
  invoice: {
    issueDate: null
  }
},
mutations {
  updateInvoiceIssueDate (state, issueDate) {
    state.invoice.issueDate = issueDate
  }
}