Skip to content

Commit 0cac8c4

Browse files
committed
fix(DsfrToggleSwitch): ajoute la prop name qui sera propagée à l'input
fixes #994
1 parent 5a7e836 commit 0cac8c4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/components/DsfrToggleSwitch/DsfrToggleSwitch.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ Le `DsfrToggleSwitch` est un composant Vue versatile, conçu pour permettre à l
1515
| `modelValue` | `boolean` | | | Valeur booléenne associée à la case à cocher |
1616
| `disabled` | `boolean` | | | Valeur booléenne pour désactiver le toggle |
1717
| `hint` | `string` | | | Texte d'information complémentaire affiché en dessous de l'interrupteur |
18-
| `label` | `string` | `false` | | Texte du label associé à l'interrupteur |
18+
| `label` | `string` | `''` | | Texte du label associé à l'interrupteur |
19+
| `name` | `string` | `undefined` | | Attribut `name` de l’input |
1920
| `labelLeft` | `boolean` | `false` | | Permet d'afficher le label à gauche de l'interrupteur |
2021
| `borderBottom` | `boolean` | `false` | | Affiche une bordure sous l'interrupteur et le label |
2122
| `inputId` | `string` | `getRandomId('toggle')` | | Identifiant unique pour le toggle. Utilisé pour l'accessibilité. |
22-
| `activeText` | `string` | `Activé` | | Texte à afficher sous l'interrupteur lorsqu'il est activé |
23-
| `inactiveText` | `string` | `Désactivé` | | Texte à afficher sous l'interrupteur lorsqu'il est désactivé |
24-
| `notext` | `boolean` | `false` | | Désactive l'affichage de activeText et inactiveText |
23+
| `activeText` | `string` | `Activé` | | Texte à afficher sous l'interrupteur lorsqu'il est activé |
24+
| `inactiveText` | `string` | `Désactivé` | | Texte à afficher sous l'interrupteur lorsqu'il est désactivé |
25+
| `noText` | `boolean` | `false` | | Désactive l'affichage de activeText et inactiveText |
2526

2627
## 📡 Évenements
2728

src/components/DsfrToggleSwitch/DsfrToggleSwitch.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export type DsfrToggleSwitchProps = {
99
activeText?: string
1010
inactiveText?: string
1111
noText?: boolean
12+
name?: string
1213
}

src/components/DsfrToggleSwitch/DsfrToggleSwitch.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const props = withDefaults(defineProps<DsfrToggleSwitchProps>(), {
1616
activeText: 'Activé',
1717
inactiveText: 'Désactivé',
1818
noText: false,
19+
name: undefined,
1920
})
2021
2122
defineEmits<{ (e: 'update:modelValue', payload: boolean): void }>()
@@ -42,6 +43,7 @@ const labelId = computed(() => {
4243
:data-testid="inputId"
4344
class="fr-toggle__input"
4445
:aria-describedby="labelId"
46+
:name="name"
4547
@input="$emit('update:modelValue', ($event.target as HTMLInputElement).checked)"
4648
>
4749
<label

0 commit comments

Comments
 (0)