-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: rgaa fix sur l'input contact page besoin plus info #6361
Merged
Viczei
merged 10 commits into
dev
from
6295-modale-service-près-de-moi-formulaire-de-recherche-non-accessible
Dec 19, 2024
The head ref may contain hidden characters: "6295-modale-service-pr\u00E8s-de-moi-formulaire-de-recherche-non-accessible"
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
55ad4ee
fix: rgaa fix sur l'input contact page besoin plus info
ef12110
chore: clean
354564e
chore: fix tu
3ec16ff
chore: clean test e2e
bd7cc47
chore: clean test e2e
1f07706
chore: clean test e2e
0ed3934
chore: mise à jour de la couleur du svg
46b72b9
refactor
1c5def0
chore: clean test e2e
aa993e7
Merge branch 'dev' into 6295-modale-service-près-de-moi-formulaire-de…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
packages/code-du-travail-frontend/public/static/assets/img/srdt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import { fr } from "@codegouvfr/react-dsfr"; | ||
import { Container } from "../layout/Container"; | ||
import { useState } from "react"; | ||
import { useEffect, useState } from "react"; | ||
import { useNeedMoreInfoEvents } from "../layout/infos/tracking"; | ||
import Image from "next/image"; | ||
import { Input } from "@codegouvfr/react-dsfr/Input"; | ||
|
@@ -17,6 +17,9 @@ import { | |
export const BesoinPlusInformations = () => { | ||
const [department, setDepartment] = useState<string>(""); | ||
const [hasSearched, setHasSearched] = useState<boolean>(false); | ||
const [hasError, setHasError] = useState<boolean>(false); | ||
const [inputRef, setInputRef] = useState<HTMLInputElement | null>(); | ||
const [linkRef, setLinkRef] = useState<HTMLAnchorElement | null>(); | ||
const [result, setResult] = useState<undefined | ServiceRenseignement>( | ||
undefined | ||
); | ||
|
@@ -33,12 +36,21 @@ export const BesoinPlusInformations = () => { | |
emitTrackNumber(); | ||
}; | ||
|
||
useEffect(() => { | ||
setHasError(hasSearched && !result); | ||
if (hasError) { | ||
inputRef?.focus(); | ||
} | ||
}, [hasSearched, result]); | ||
|
||
useEffect(() => { | ||
linkRef?.focus(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. celui ci pour focus le lien |
||
}, [linkRef]); | ||
return ( | ||
<Container> | ||
<h1 id="mentions-legales" className={fr.cx("fr-mt-0")}> | ||
Besoin de plus d'informations | ||
</h1> | ||
|
||
<p className={fr.cx("fr-mt-6w", "fr-mb-6w", "fr-text--lg")}> | ||
Les services du ministère du Travail en région informent, conseillent et | ||
orientent les salariés et les employeurs du secteur privé sur leurs | ||
|
@@ -64,6 +76,17 @@ export const BesoinPlusInformations = () => { | |
<Input | ||
id="search-service" | ||
label="Saisissez le numéro de votre département" | ||
stateRelatedMessage={ | ||
<> | ||
{hasError && ( | ||
<span> | ||
Aucun service de renseignement n'a été trouvé pour ce | ||
département. | ||
</span> | ||
)} | ||
</> | ||
} | ||
state={hasError ? "error" : undefined} | ||
nativeInputProps={{ | ||
maxLength: 3, | ||
onChange: (e) => setDepartment(e.target.value), | ||
|
@@ -72,6 +95,8 @@ export const BesoinPlusInformations = () => { | |
onSearchInput(); | ||
} | ||
}, | ||
"aria-invalid": hasError ? true : undefined, | ||
ref: setInputRef, | ||
}} | ||
addon={ | ||
<Button | ||
|
@@ -91,19 +116,11 @@ export const BesoinPlusInformations = () => { | |
href={result.url} | ||
target="_blank" | ||
data-testid="result-search-service" | ||
ref={setLinkRef} | ||
> | ||
{result.url} | ||
</a> | ||
)} | ||
{hasSearched && !result && ( | ||
<p | ||
className={fr.cx("fr-error-text", "fr-text--md")} | ||
data-testid="result-search-service-failed" | ||
> | ||
Aucun service de renseignement n'a été trouvé pour ce | ||
département. | ||
</p> | ||
)} | ||
</section> | ||
<Alert | ||
severity={"info"} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ca c'est pour focus l'input lorsqu'il y a une erreur