breaking(form): do not prevent default behavior on submit event (#1170)

* breaking(form): do not prevent default behavior on submit event

* docs(form): add "Prevent default behavior" example
This commit is contained in:
metonym 2022-03-13 19:04:10 -07:00 committed by GitHub
commit ef46f350be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -60,3 +60,17 @@ components: ["Form", "FormGroup"]
</FormGroup>
<Button type="submit">Submit</Button>
</Form>
### Prevent default behavior
The forwarded `submit` event is not modified. Use `e.preventDefault()` to prevent the native form submission behavior.
```
<Form on:submit={e => {
e.preventDefault();
console.log("submit", e);
}}>
<Checkbox id="checkbox-0" labelText="Checkbox Label" checked />
<Button type="submit">Submit</Button>
</Form>
```

View file

@ -13,7 +13,7 @@
on:mouseover
on:mouseenter
on:mouseleave
on:submit|preventDefault
on:submit
>
<slot />
</form>