Skip to content

Commit

Permalink
DOC: Add note about form prevent_default behavior. (#1343)
Browse files Browse the repository at this point in the history
* Add note about form prevent_default behavior.

* Make the default behavior clear on forms with attached event handlers.
  • Loading branch information
vgobbo committed Aug 17, 2023
1 parent bcebaaf commit 8946944
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/guide/src/en/interactivity/event_handlers.md
Expand Up @@ -51,6 +51,8 @@ Any event handlers will still be called.

> Normally, in React or JavaScript, you'd call "preventDefault" on the event in the callback. Dioxus does _not_ currently support this behavior. Note: this means you cannot conditionally prevent default behavior based on the data in the event.
> Note about forms: if an event handler is attached to the `onsubmit` event of a form, default behavior is to **not submit it**, meaning having `prevent_default: "onsubmit"` will submit it in this case.
## Handler Props

Sometimes, you might want to make a component that accepts an event handler. A simple example would be a `FancyButton` component, which accepts an `on_click` handler:
Expand Down
2 changes: 2 additions & 0 deletions docs/guide/src/pt-br/interactivity/event_handlers.md
Expand Up @@ -64,3 +64,5 @@ Então, você pode usá-lo como qualquer outro manipulador:
> Nota: assim como qualquer outro atributo, você pode nomear os manipuladores como quiser! Embora eles devam começar com `on`, para que o prop seja automaticamente transformado em um `EventHandler` no local da chamada.
>
> Você também pode colocar dados personalizados no evento, em vez de, por exemplo, `MouseData`
> Nota sobre formulários: se um manipulador de evento está anexado ao evento `onsubmit` em um formulário, o comportamento padrão é de **não submetê-lo**. Portanto, especificar `prevent_default: "onsubmit"` irá submetê-lo.

0 comments on commit 8946944

Please sign in to comment.