Skip to content

Commit 9ab5e26

Browse files
authored
fix(accessibilite): restitution des messages d'erreur à l'utilisateur (règle 7.5) (#6790)
1 parent 093f874 commit 9ab5e26

File tree

85 files changed

+712
-711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+712
-711
lines changed

packages/code-du-travail-frontend/src/modules/besoin-plus-informations/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import { useNeedMoreInfoEvents } from "../layout/footer/infos/tracking";
77
import Image from "next/image";
88
import { Input } from "@codegouvfr/react-dsfr/Input";
99
import { Button } from "@codegouvfr/react-dsfr/Button";
10-
import { Alert } from "@codegouvfr/react-dsfr/Alert";
1110
import {
1211
getServiceInfo,
1312
ServiceRenseignement,
1413
} from "./data/servicesDeRenseignement";
1514
import Link from "../common/Link";
1615
import { defaultInputStyle } from "../outils/common/styles/input";
16+
import { AccessibleAlert } from "../outils/common/components/AccessibleAlert";
1717

1818
export const BesoinPlusInformations = () => {
1919
const [department, setDepartment] = useState<string>("");
@@ -123,7 +123,7 @@ export const BesoinPlusInformations = () => {
123123
</Link>
124124
)}
125125
</section>
126-
<Alert
126+
<AccessibleAlert
127127
severity={"info"}
128128
small
129129
description={
@@ -148,7 +148,7 @@ export const BesoinPlusInformations = () => {
148148
</ul>
149149
</>
150150
}
151-
></Alert>
151+
/>
152152
</Container>
153153
);
154154
};

packages/code-du-travail-frontend/src/modules/common/DisplayContent.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import parse, {
55
HTMLReactParserOptions,
66
Text,
77
} from "html-react-parser";
8-
import Alert from "@codegouvfr/react-dsfr/Alert";
98
import React, { ElementType, JSX } from "react";
109
import { AccordionWithAnchor } from "./AccordionWithAnchor";
1110
import { v4 as generateUUID } from "uuid";
@@ -16,6 +15,7 @@ import { slugify } from "@socialgouv/cdtn-utils";
1615
import { captureException } from "@sentry/nextjs";
1716
import { toUrl } from "../utils/url";
1817
import { xssWrapper } from "../utils/xss";
18+
import { AccessibleAlert } from "../outils/common/components/AccessibleAlert";
1919

2020
export type numberLevel = 2 | 3 | 4 | 5 | 6;
2121

@@ -279,12 +279,12 @@ const options = (titleLevel: numberLevel): HTMLReactParserOptions => {
279279
}
280280
if (domNode.name === "div" && domNode.attribs.class === "alert") {
281281
return (
282-
<Alert
282+
<AccessibleAlert
283283
severity="info"
284284
small
285285
description={renderChildren(domNode, true, options(titleLevel))}
286-
className={fr.cx("fr-mt-2w", "fr-pb-2w")}
287-
></Alert>
286+
className={["fr-mt-2w", "fr-pb-2w"]}
287+
/>
288288
);
289289
}
290290
if (domNode.name === "div" && domNode.attribs.class === "infographic") {

packages/code-du-travail-frontend/src/modules/common/__tests__/__snapshots__/DisplayContent.test.tsx.snap

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -532,19 +532,18 @@ exports[`DisplayContent Alerts should replace div with alert class in li compone
532532
</p>
533533
<br />
534534
<div
535-
class="fr-alert fr-alert--info fr-alert--sm fr-mt-2w fr-pb-2w"
536-
id="fr-alert-:rh:"
535+
aria-atomic="true"
536+
aria-live="off"
537+
class="fr-alert fr-alert--info fr-mt-2w fr-pb-2w fr-alert--sm"
537538
>
538-
<div>
539-
<p
540-
class="fr-mt-2w"
541-
>
542-
<strong>
543-
Attention :
544-
</strong>
545-
En l’absence d’écrit, l’employeur peut être condamné à une amende de 3.750 € ou 7.500 € en cas de récidive.
546-
</p>
547-
</div>
539+
<p
540+
class="fr-mt-2w"
541+
>
542+
<strong>
543+
Attention :
544+
</strong>
545+
En l’absence d’écrit, l’employeur peut être condamné à une amende de 3.750 € ou 7.500 € en cas de récidive.
546+
</p>
548547
</div>
549548
</li>
550549
</ul>
@@ -553,19 +552,18 @@ exports[`DisplayContent Alerts should replace div with alert class in li compone
553552

554553
exports[`DisplayContent Alerts should replace div with alert class to Alert component 1`] = `
555554
<div
556-
class="fr-alert fr-alert--info fr-alert--sm fr-mt-2w fr-pb-2w"
557-
id="fr-alert-:rg:"
555+
aria-atomic="true"
556+
aria-live="off"
557+
class="fr-alert fr-alert--info fr-mt-2w fr-pb-2w fr-alert--sm"
558558
>
559-
<div>
560-
<p
561-
class="fr-mt-2w"
562-
>
563-
<strong>
564-
Attention :
565-
</strong>
566-
En l’absence d’écrit, l’employeur peut être condamné à une amende de 3.750 € ou 7.500 € en cas de récidive.
567-
</p>
568-
</div>
559+
<p
560+
class="fr-mt-2w"
561+
>
562+
<strong>
563+
Attention :
564+
</strong>
565+
En l’absence d’écrit, l’employeur peut être condamné à une amende de 3.750 € ou 7.500 € en cas de récidive.
566+
</p>
569567
</div>
570568
`;
571569

@@ -612,7 +610,7 @@ exports[`DisplayContent Infographic should replace div with infographic class to
612610
</div>
613611
<div
614612
class="fr-tile fr-enlarge-link fr-tile--vertical fr-tile--download"
615-
id="fr-tile-:ri:"
613+
id="fr-tile-:rg:"
616614
>
617615
<div
618616
class="fr-tile__body"

packages/code-du-travail-frontend/src/modules/convention-collective/AgreementSearch/AgreementSearchInput.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"use client";
22
import { fr } from "@codegouvfr/react-dsfr";
3-
import Alert from "@codegouvfr/react-dsfr/Alert";
43
import { getRouteBySource, SOURCES } from "@socialgouv/cdtn-utils";
54
import { createElement, ReactNode, useState } from "react";
65

76
import { Autocomplete } from "../../common/Autocomplete";
87
import { searchAgreement } from "../search";
98
import { useAgreementSearchTracking } from "../tracking";
109
import { Agreement } from "src/modules/outils/indemnite-depart/types";
10+
import { AccessibleAlert } from "src/modules/outils/common/components/AccessibleAlert";
1111

1212
type Props = {
1313
onSearch?: (query: string, value?: Agreement[]) => void;
@@ -129,9 +129,9 @@ export const AgreementSearchInput = ({
129129
/>
130130
</div>
131131
{searchState === "notFoundSearch" && (
132-
<Alert
133-
className={fr.cx("fr-mt-2w")}
134-
as={`h${(level ?? 2) + 1}` as "h3" | "h4"}
132+
<AccessibleAlert
133+
className={["fr-mt-2w"]}
134+
titleAs={`h${(level ?? 2) + 1}` as "h3" | "h4"}
135135
title="Vous ne trouvez pas votre convention collective&nbsp;?"
136136
description={
137137
<>
@@ -158,8 +158,8 @@ export const AgreementSearchInput = ({
158158
/>
159159
)}
160160
{selectedAgreement && selectedAgreementAlert?.(selectedAgreement) && (
161-
<Alert
162-
className={fr.cx("fr-mt-2w")}
161+
<AccessibleAlert
162+
className={["fr-mt-2w"]}
163163
title="Nous n’avons pas de réponse pour cette convention collective"
164164
description={selectedAgreementAlert(selectedAgreement)}
165165
severity="warning"

packages/code-du-travail-frontend/src/modules/convention-collective/LegiFranceSearch.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { fr } from "@codegouvfr/react-dsfr";
33
import Input from "@codegouvfr/react-dsfr/Input";
44
import Button from "@codegouvfr/react-dsfr/Button";
55
import { push as matopush } from "@socialgouv/matomo-next";
6-
import Alert from "@codegouvfr/react-dsfr/Alert";
76
import { css } from "@styled-system/css";
7+
import { AccessibleAlert } from "../outils/common/components/AccessibleAlert";
88

99
type Props = {
1010
idcc: string;
@@ -131,10 +131,10 @@ export function LegiFranceSearch({ idcc, shortTitle }: Props) {
131131
</div>
132132
</form>
133133

134-
<Alert
134+
<AccessibleAlert
135135
severity="info"
136136
small
137-
className={fr.cx("fr-mb-0")}
137+
className={["fr-mb-0"]}
138138
description="Selon le thème, un accord collectif d'entreprise peut prévoir des règles différentes par rapport à la convention collective."
139139
data-testid="agreement-search-alert"
140140
/>

packages/code-du-travail-frontend/src/modules/documents/type.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export type RelatedItem = Pick<DocumentElastic, "title"> & {
2323
url: string;
2424
};
2525

26-
// @TODO : utiliser LinkedContent dans cdtn-types une fois le package publié
2726
export type LinkedContent = Pick<DocumentElastic, "title"> & {
2827
source: Source;
2928
slug: string;

packages/code-du-travail-frontend/src/modules/droit-du-travail/Introduction.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import { fr } from "@codegouvfr/react-dsfr";
3-
import Alert from "@codegouvfr/react-dsfr/Alert";
3+
import { AccessibleAlert } from "../outils/common/components/AccessibleAlert";
44

55
const Introduction = () => (
66
<div className={fr.cx("fr-grid-row", "fr-grid-row--center")}>
@@ -28,9 +28,9 @@ const Introduction = () => (
2828
Le droit du travail est un droit en constante évolution car il comprend
2929
des enjeux sociaux, économiques et politiques forts.
3030
</p>
31-
<Alert
31+
<AccessibleAlert
3232
severity="info"
33-
className={fr.cx("fr-mt-4w")}
33+
className={["fr-mt-4w"]}
3434
title="Le droit du travail, ce n'est pas..."
3535
description="Le droit du travail ne concerne pas les travailleurs qui sont soumis au droit public (par exemple, les fonctionnaires), les travailleurs indépendants (artisan, commerçant, professions libérales…), les bénévoles et les dirigeants d’entreprise."
3636
/>

packages/code-du-travail-frontend/src/modules/droit-du-travail/__tests__/__snapshots__/DroitDuTravailWrapper.test.tsx.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ exports[`<DroitDuTravailWrapper /> renders correctly 1`] = `
8787
Le droit du travail est un droit en constante évolution car il comprend des enjeux sociaux, économiques et politiques forts.
8888
</p>
8989
<div
90+
aria-atomic="true"
91+
aria-live="off"
9092
class="fr-alert fr-alert--info fr-mt-4w"
91-
id="fr-alert-:r2:"
9293
>
9394
<h3
9495
class="fr-alert__title"

packages/code-du-travail-frontend/src/modules/droit-du-travail/__tests__/__snapshots__/Introduction.test.tsx.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ exports[`<Introduction /> renders correctly 1`] = `
3535
Le droit du travail est un droit en constante évolution car il comprend des enjeux sociaux, économiques et politiques forts.
3636
</p>
3737
<div
38+
aria-atomic="true"
39+
aria-live="off"
3840
class="fr-alert fr-alert--info fr-mt-4w"
39-
id="fr-alert-:r0:"
4041
>
4142
<h3
4243
class="fr-alert__title"

packages/code-du-travail-frontend/src/modules/enterprise/EnterpriseAgreementSearch/EnterpriseAgreementSearchInput.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Image from "next/image";
44
import Button from "@codegouvfr/react-dsfr/Button";
55
import Input from "@codegouvfr/react-dsfr/Input";
66
import Badge from "@codegouvfr/react-dsfr/Badge";
7-
import Alert from "@codegouvfr/react-dsfr/Alert";
87
import { EnterpriseCard } from "./EnterpriseCard";
98
import { createElement, ReactNode, useEffect, useRef, useState } from "react";
109
import { css } from "@styled-system/css";
@@ -21,6 +20,7 @@ import { useEnterpriseAgreementSearchTracking } from "./tracking";
2120
import { Agreement } from "src/modules/outils/indemnite-depart/types";
2221
import { scrollToTop } from "src/modules/outils/common/utils";
2322
import { ApiGeoResult } from "./searchCities";
23+
import { AccessibleAlert } from "src/modules/outils/common/components/AccessibleAlert";
2424

2525
type Props = {
2626
widgetMode?: boolean;
@@ -256,8 +256,8 @@ export const EnterpriseAgreementSearchInput = ({
256256
</div>
257257

258258
{selectedAgreement && selectedAgreementAlert?.(selectedAgreement) && (
259-
<Alert
260-
className={fr.cx("fr-mt-2w")}
259+
<AccessibleAlert
260+
className={["fr-mt-2w"]}
261261
title="Nous n’avons pas de réponse pour cette convention collective"
262262
description={selectedAgreementAlert(selectedAgreement)}
263263
severity="warning"
@@ -415,9 +415,9 @@ export const EnterpriseAgreementSearchInput = ({
415415
</div>
416416
)}
417417
{searchState === "notFoundSearch" && (
418-
<Alert
418+
<AccessibleAlert
419419
title="Vous ne trouvez pas votre entreprise&nbsp;?"
420-
as={`h${(level ?? 2) + 1}` as "h3" | "h4"}
420+
titleAs={`h${(level ?? 2) + 1}` as "h3" | "h4"}
421421
description={
422422
<>
423423
<p>Il peut y avoir plusieurs explications à cela&nbsp;:</p>

0 commit comments

Comments
 (0)