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

[Bug] append-to-body tag auto submit form #389

Closed
lauranoreen opened this issue Dec 4, 2019 · 3 comments
Closed

[Bug] append-to-body tag auto submit form #389

lauranoreen opened this issue Dec 4, 2019 · 3 comments

Comments

@lauranoreen
Copy link

lauranoreen commented Dec 4, 2019

I updated the vue2-datepicker version to 3.2. After that I had to rewrite my datepicker implementations. In my case I use different bootstrap vue modals to handle forms. In these forms I have datepickers but the calendar appears behind the modal (screenshot) so I added :append-to-body="false" to use the calendar again. After that I noticed that by changing the month (with the arrows) my form will automatically submitted.

grafik
grafik

Here is a quick example (without modal):

<template>
<div>
<b-form @submit="onSubmit">
      <date-picker v-model="test" format="DD.MM.YYYY" :append-to-body="false"></date-picker>
      <b-button type="submit" variant="primary">Senden</b-button>
</b-form>
</div>
</template>

<script>
import DatePicker from 'vue2-datepicker'
import 'vue2-datepicker/index.css'
import 'vue2-datepicker/locale/de'

export default {
  components: {
    DatePicker
  },
  data() {
    return {
      test: ''
    }
  },
  methods: {
    onSubmit(evt) {
      console.log('submit', this.test)
      evt.preventDefault()
    }
  }
}
</script>

If I delete the append-to-body tag the arrows from the calendar would not submit the form.
Any ideas how to fix it?

Vue2-datepicker version: 3.2.1
Vue version: 2.6.10
Browser: Firefox

@mengxiong10
Copy link
Owner

the calendar appears behind the modal >> you can change the zIndex of .mx-datepicker-popup.

For the second problem:
The arrow is a Button without type, Button's type is 'submit' by default, so it'll submit the form.
I'll change the Button type to 'button' soon.

My suggestion is that you remove append-to-body now and modify the zIndex to see if it works

@lauranoreen
Copy link
Author

Thanks for your quick reply.
By changing the z index and removing the append-to-body tag the problem is fixed.

@mengxiong10
Copy link
Owner

v3.2.2 fixed the button type.

lleizh pushed a commit to lleizh/vue2-datepicker that referenced this issue Dec 6, 2019
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

2 participants