Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
blerg-rush opened this issue Nov 27, 2019 · 0 comments
Open

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

blerg-rush opened this issue Nov 27, 2019 · 0 comments

Comments

@blerg-rush
Copy link

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

  • Vue 2.6.10
  • Vuex 3.1.2
  • Google Chrome 78.0.3904.97

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
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant