Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/shared/Fieldset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const Fieldset = memo(

const errorDescId = `${id}-desc-error`;
const successDescId = `${id}-desc-valid`;
const infoDescId = `${id}-desc-info`;
const messagesWrapperId = `${id}-messages`;

const radioName = (function useClosure() {
Expand Down Expand Up @@ -148,6 +149,17 @@ export const Fieldset = memo(
return renderOption({ option: options[0], i: undefined });
}

const messageId = (() => {
switch (state) {
case "error":
return errorDescId;
case "success":
return successDescId;
case "info":
return infoDescId;
Copy link
Contributor Author

@m-maillot m-maillot Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai ajouté un id sur l'info car quand on a une info, il faut la lier avec le aria-describedby

}
})();

return (
<fieldset
id={id}
Expand Down Expand Up @@ -184,6 +196,7 @@ export const Fieldset = memo(
fr.cx("fr-fieldset__legend", "fr-text--regular"),
classes.legend
)}
aria-describedby={messageId}
>
{legend}
{hintText !== undefined && (
Expand All @@ -197,18 +210,11 @@ export const Fieldset = memo(
<div
className={fr.cx("fr-messages-group")}
id={messagesWrapperId}
aria-live="assertive"
aria-live={state === "error" ? "assertive" : undefined}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le aria-live assertive est à renseigner seulement si c'est une erreur.

>
{stateRelatedMessage !== undefined && (
<p
id={(() => {
switch (state) {
case "error":
return errorDescId;
case "success":
return successDescId;
}
})()}
id={messageId}
className={fr.cx(
"fr-message",
(() => {
Expand Down