Skip to content

Commit 85b3748

Browse files
committed
fix: ♿ Corrige des attributs aria-*
1 parent 22e5bc4 commit 85b3748

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

src/components/DsfrCheckbox/DsfrCheckbox.spec.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('DsfrCheckbox', () => {
1212
const validMessage = 'Message de succès'
1313

1414
// When
15-
const { getByText, getByLabelText } = render(CheckBox, {
15+
const { getByText, getByLabelText, getByRole } = render(CheckBox, {
1616
global: {
1717
components: {
1818
VIcon,
@@ -26,11 +26,14 @@ describe('DsfrCheckbox', () => {
2626
},
2727
})
2828

29+
const input = getByRole('checkbox')
2930
const labelEl = getByText(label)
3031
const inputCheckBox = getByLabelText(label)
3132

3233
// Then
3334
expect(labelEl).toHaveClass('fr-label')
35+
expect(input.checked).toBe(true)
36+
expect(input).toHaveAttribute('aria-checked', 'true')
3437
expect(inputCheckBox).toBeInTheDocument()
3538
expect(labelEl.getAttribute('for')).toBe(inputCheckBox.id)
3639
expect(inputCheckBox.getAttribute('type')).toBe('checkbox')
@@ -40,12 +43,12 @@ describe('DsfrCheckbox', () => {
4043
it('should render a checkbox with label in div', () => {
4144
// Given
4245
const label = 'Check box label'
43-
const modelValue = true
46+
const modelValue = false
4447
const disabled = true
4548
const errorMessage = 'Message d’erreur'
4649

4750
// When
48-
const { getByText, getByLabelText } = render(CheckBox, {
51+
const { getByText, getByLabelText, getByRole } = render(CheckBox, {
4952
global: {
5053
components: {
5154
VIcon,
@@ -60,12 +63,15 @@ describe('DsfrCheckbox', () => {
6063
},
6164
})
6265

66+
const input = getByRole('checkbox')
6367
const labelEl = getByText(label)
6468
const inputCheckBox = getByLabelText(label)
6569

6670
// Then
6771
expect(labelEl).toHaveClass('fr-label')
6872
expect(inputCheckBox).toBeInTheDocument()
73+
expect(input.checked).toBe(false)
74+
expect(input).toHaveAttribute('aria-checked', 'false')
6975
expect(labelEl.getAttribute('for')).toBe(inputCheckBox.id)
7076
expect(inputCheckBox.getAttribute('type')).toBe('checkbox')
7177
expect(inputCheckBox).toHaveAttribute('disabled')

src/components/DsfrCheckbox/DsfrCheckbox.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
:id="id"
1111
:name="name"
1212
type="checkbox"
13+
role="checkbox"
1314
:checked="modelValue"
15+
:aria-checked="modelValue"
1416
:disabled="disabled"
1517
:data-testid="`input-checkbox-${id}`"
1618
:data-test="`input-checkbox-${id}`"

src/components/DsfrCheckbox/DsfrCheckboxSet.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
:disabled="disabled"
1111
>
1212
<legend
13-
id="checkboxes-legend"
13+
:id="titleId"
1414
class="fr-fieldset__legend fr-text--regular"
1515
>
1616
{{ legend }}
1717
</legend>
18-
<div class="fr-fieldset__content">
18+
<div
19+
class="fr-fieldset__content"
20+
role="group"
21+
:aria-labelledby="titleId"
22+
>
1923
<DsfrCheckbox
2024
v-for="option in options"
2125
:id="option.id"
@@ -43,6 +47,7 @@
4347

4448
<script>
4549
import DsfrCheckbox from './DsfrCheckbox.vue'
50+
import { getRandomId } from '../../utils/random-utils.js'
4651
4752
export default {
4853
name: 'DsfrCheckboxSet',
@@ -52,6 +57,12 @@ export default {
5257
},
5358
5459
props: {
60+
titleId: {
61+
type: String,
62+
default () {
63+
return getRandomId('checkbox', 'group')
64+
},
65+
},
5566
disabled: Boolean,
5667
inline: Boolean,
5768
errorMessage: {

src/components/DsfrTabs/DsfrTabItem.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
@click="$emit('click', $event)"
1616
@keydown.right="$emit('next')"
1717
@keydown.left="$emit('previous')"
18+
@keydown.down="$emit('next')"
19+
@keydown.up="$emit('previous')"
20+
@keydown.home="$emit('first')"
21+
@keydown.end="$emit('last')"
1822
>
1923
<span
2024
v-if="icon"
@@ -49,7 +53,7 @@ export default {
4953
},
5054
},
5155
52-
emits: ['click', 'next', 'previous'],
56+
emits: ['click', 'next', 'previous', 'first', 'last'],
5357
5458
watch: {
5559
selected (newValue, oldValue) {

0 commit comments

Comments
 (0)