<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-toast-region/usage/ in the magma monorepo.
-->

# mds-toast-region - mistakes

> The API of this component: [`AGENTS.md`](AGENTS.md).

Common incorrect uses of `<mds-toast-region>`. Each entry pairs the wrong form with the right one and a one-line reason. System-wide rules live in [`agents/mistakes.md`](../../../../agents/mistakes.md) - they apply here too but are not repeated.

#### Do Not Place a Region in Every Page or Component

Two regions at the same edge draw their toasts at the same place, one over the other, which is the problem the region solves. A region created together with its message is also not in the page before it, so the message may not be announced.

```html
<!-- INCORRECT - one region per form, created with the message -->
<form>
  <mds-toast-region>
    <mds-toast visible>Modulo inviato</mds-toast>
  </mds-toast-region>
</form>

<!-- CORRECT - one region in the shell, the toasts appended to it -->
<mds-toast-region></mds-toast-region>
```

#### Do Not Set `position` on the Toasts Inside a Region

The region gives its `position` to every toast inside it, so the one set on a toast is replaced. Set it on the region.

```html
<!-- INCORRECT - replaced by the region -->
<mds-toast-region>
  <mds-toast visible position="top-right">Impostazioni aggiornate</mds-toast>
</mds-toast-region>

<!-- CORRECT -->
<mds-toast-region position="top-right">
  <mds-toast visible>Impostazioni aggiornate</mds-toast>
</mds-toast-region>
```

#### Do Not Send a Message About an Open Dialog to the Region

While an `mds-modal` is open, everything outside it is inert, the region included: its toast cannot be used and is not announced. Show the message inside the dialog.

```html
<!-- INCORRECT - the error of the dialog goes behind it -->
<mds-modal opened>
  <form>...</form>
</mds-modal>
<mds-toast-region>
  <mds-toast visible variant="error" duration="0">Salvataggio non riuscito</mds-toast>
</mds-toast-region>

<!-- CORRECT - the error is in the dialog -->
<mds-modal opened>
  <mds-banner variant="error">Salvataggio non riuscito</mds-banner>
  <form></form>
</mds-modal>
```
