Skip to content

Commit abdb540

Browse files
committed
fix: ♿ Corrige des oublis pour a11y
1 parent 159af91 commit abdb540

File tree

6 files changed

+79
-9
lines changed

6 files changed

+79
-9
lines changed

src/components/DsfrRadioButton/DsfrRadioButton.stories.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,9 @@ export const RadioButton = (args, { argTypes }) => ({
3333
template: `
3434
<div :data-rf-theme="dark ? 'dark' : ''" style="background-color: var(--w); padding: 1rem;">
3535
<DsfrRadioButton
36-
v-for="option in options"
37-
:key="option.value"
38-
:label="option.label"
39-
:disabled="option.disabled"
36+
v-for="option of options"
4037
:modelValue="modelValue"
41-
:value="option.value"
42-
:hint="option.hint"
38+
v-bind="option"
4339
@update:modelValue="updateCheckedValue($event)"
4440
/>
4541
</div>
@@ -62,16 +58,19 @@ RadioButton.args = {
6258
label: 'Valeur 1',
6359
value: '1',
6460
hint: 'Description 1',
61+
name: 'Choix',
6562
},
6663
{
6764
label: 'Valeur 2',
6865
value: '2',
6966
disabled: true,
7067
hint: 'Description 2',
68+
name: 'Choix',
7169
},
7270
{
7371
label: 'Valeur 3',
7472
value: '3',
73+
name: 'Choix',
7574
},
7675
],
7776
}

src/components/DsfrRadioButton/DsfrRadioButton.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
<input
44
:id="id"
55
type="radio"
6+
role="radio"
7+
:name="name"
68
:value="value"
79
:checked="modelValue === value"
10+
:aria-checked="modelValue === value"
811
:disabled="disabled"
912
@click="$emit('update:modelValue', value)"
1013
>
@@ -37,6 +40,10 @@ export default defineComponent({
3740
return getRandomId('basic', 'checkbox')
3841
},
3942
},
43+
name: {
44+
type: String,
45+
required: true,
46+
},
4047
modelValue: {
4148
type: [String, Number],
4249
default: '',
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { mount } from '@cypress/vue'
2+
import DsfrRadioButtonSet from './DsfrRadioButtonSet.vue'
3+
import VIcon from '../../icons.js'
4+
5+
import '../../main.css'
6+
7+
describe('DsfrRadioButtonSet', () => {
8+
it('should mount Tabs', () => {
9+
mount(DsfrRadioButtonSet, {
10+
global: {
11+
components: {
12+
VIcon,
13+
},
14+
},
15+
props: {
16+
legend: 'Légende des champs',
17+
selectedValue: 1,
18+
inline: false,
19+
modelValue: '1',
20+
name: 'radiobuttonset',
21+
options: [
22+
{
23+
label: 'Valeur 1',
24+
value: '1',
25+
hint: 'Description 1',
26+
},
27+
{
28+
label: 'Valeur 2',
29+
value: '2',
30+
disabled: true,
31+
hint: 'Description 2',
32+
},
33+
{
34+
label: 'Valeur 3',
35+
value: '3',
36+
},
37+
],
38+
},
39+
})
40+
41+
cy.tab()
42+
.type(' ')
43+
.get('.fr-radio-group:first-child input')
44+
.should('have.focus')
45+
// .click()
46+
.type('{rightArrow}')
47+
.get('.fr-radio-group:nth-child(3) input')
48+
.should('have.focus')
49+
})
50+
})

src/components/DsfrRadioButton/DsfrRadioButtonSet.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('DsfrRadioButtonSet', () => {
1111
const selectedValue = 1
1212

1313
// When
14-
const { getByText } = render(RadioButtonSet, {
14+
const { getByText, getByRole } = render(RadioButtonSet, {
1515
global: {
1616
components: {
1717
VIcon,
@@ -23,6 +23,7 @@ describe('DsfrRadioButtonSet', () => {
2323
},
2424
})
2525

26+
getByRole('radiogroup')
2627
const legendEl = getByText(legend)
2728

2829
// Then

src/components/DsfrRadioButton/DsfrRadioButtonSet.stories.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const RadioButtonSet = (args) => ({
5050
<DsfrRadioButtonSet
5151
:legend="legend"
5252
v-model="selectedValue"
53+
name="radio-set"
5354
:options="options"
5455
:inline="inline"
5556
@update:model-value="onChange"
@@ -90,6 +91,7 @@ export const RadioButtonSetInError = (args) => ({
9091
<DsfrRadioButtonSet
9192
:legend="legend"
9293
v-model="selectedValue"
94+
name="radio-errors"
9395
:options="options"
9496
:disabled="disabled"
9597
:error-message="error"
@@ -135,6 +137,7 @@ export const RadioButtonSetInSuccess = (args) => ({
135137
<DsfrRadioButtonSet
136138
:legend="legend"
137139
v-model="selectedValue"
140+
name="radio-success"
138141
:options="options"
139142
:disabled="disabled"
140143
:valid-message="validMessage"
@@ -180,6 +183,7 @@ export const RadioButtonSetDisabled = (args) => ({
180183
<DsfrRadioButtonSet
181184
:legend="legend"
182185
v-model="selectedValue"
186+
name="radio-disabled"
183187
:options="options"
184188
:disabled="disabled"
185189
:inline="inline"
@@ -222,6 +226,7 @@ export const RadioButtonSetInline = (args) => ({
222226
<DsfrRadioButtonSet
223227
:legend="legend"
224228
v-model="selectedValue"
229+
name="radio-inline"
225230
:options="options"
226231
:disabled="disabled"
227232
:inline="inline"

src/components/DsfrRadioButton/DsfrRadioButtonSet.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
{{ legend }}
1818
</legend>
1919

20-
<div class="fr-fieldset__content">
20+
<div
21+
class="fr-fieldset__content"
22+
role="radiogroup"
23+
>
2124
<DsfrRadioButton
22-
v-for="option in options"
25+
v-for="option of options"
2326
:key="option.value"
27+
:name="name"
2428
v-bind="option"
2529
@update:modelValue="onChange"
2630
/>
@@ -50,6 +54,10 @@ export default {
5054
props: {
5155
disabled: Boolean,
5256
inline: Boolean,
57+
name: {
58+
type: String,
59+
default: 'no-name',
60+
},
5361
errorMessage: {
5462
type: String,
5563
default: '',

0 commit comments

Comments
 (0)