In my current project, I am utilizing the most recent version of Vue 3 without any additional vendors. After experiencing a setback in which I invested several hours attempting to uncover why my form component was triggering the submit event twice, I am left wondering if this is a bug or an anticipated behavior.
When listening for @submit on your form and subsequently $emit('submit') to enable listening to this event on the parent component, you will find that the event fires twice.
For a visual demonstration, please refer to the following pen: https://codepen.io/rekam/pen/dyeqxyy
Revised app logic goes here...
Although I can manage with specifying a distinct name for my submit event, I am curious as to why this issue occurs and whether it is intentional.
UPDATE
Upon further exploration, I discovered that enclosing the form tag within a div eliminates the second submit event. To replicate the scenario where the submit event occurs twice, you need:
- Your form serving as the top-level DOM element in your component
- Emitting an event named "submit"