Skip to content

Commit 5ea9888

Browse files
committed
fix(form): submit to current page only if action attribute is passed
1 parent 30ef70a commit 5ea9888

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/docs/page-config/ui-elements/form/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ export default definePageConfig({
2727
}),
2828
block.example("Submit", {
2929
title: "Form submit",
30-
description: "You can fire the `submit` event of a `va-form` component: for this you need to set `tag=\"form\"` to the `va-form` and have at least one inner button with `type=\"submit\"`."
30+
description: "You can fire the `submit` event of a `va-form` component: for this you need to set `tag=\"form\"` to the `va-form` and have at least one inner button with `type=\"submit\"`",
3131
}),
32+
block.alert('info', 'If `action` attribute is not provided, the `submit` event will prevent default automatically. If you want submit method to be applied to current page (native form behavior) provide `action=""`.'),
3233

3334
block.subtitle("API"),
3435
block.api("VaForm", apiDescription, apiOptions),

packages/ui/src/components/va-form/VaForm.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<component
33
class="va-form"
44
:is="tag"
5+
@submit="(e: SubmitEvent) => $attrs.action === undefined && e.preventDefault()"
56
v-bind="$attrs"
67
>
78
<slot v-bind="{ isValid, validate }" />

0 commit comments

Comments
 (0)