mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
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:
parent
2657ce71c2
commit
ef46f350be
2 changed files with 15 additions and 1 deletions
|
@ -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>
|
||||
```
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseleave
|
||||
on:submit|preventDefault
|
||||
on:submit
|
||||
>
|
||||
<slot />
|
||||
</form>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue