File tree Expand file tree Collapse file tree 1 file changed +8
-15
lines changed Expand file tree Collapse file tree 1 file changed +8
-15
lines changed Original file line number Diff line number Diff line change 1
1
import React , {
2
- useId ,
3
- memo ,
2
+ type ComponentProps ,
3
+ type CSSProperties ,
4
4
forwardRef ,
5
+ memo ,
5
6
type ReactNode ,
6
- type CSSProperties ,
7
- type ComponentProps
7
+ useId
8
8
} from "react" ;
9
9
import { symToStr } from "tsafe/symToStr" ;
10
10
import { assert } from "tsafe/assert" ;
@@ -96,8 +96,7 @@ export const Fieldset = memo(
96
96
97
97
const legendId = `${ id } -legend` ;
98
98
99
- const errorDescId = `${ id } -desc-error` ;
100
- const successDescId = `${ id } -desc-valid` ;
99
+ const messageId = `${ id } -desc` ;
101
100
const messagesWrapperId = `${ id } -messages` ;
102
101
103
102
const radioName = ( function useClosure ( ) {
@@ -184,6 +183,7 @@ export const Fieldset = memo(
184
183
fr . cx ( "fr-fieldset__legend" , "fr-text--regular" ) ,
185
184
classes . legend
186
185
) }
186
+ aria-describedby = { state !== "default" ? messageId : undefined }
187
187
>
188
188
{ legend }
189
189
{ hintText !== undefined && (
@@ -197,18 +197,11 @@ export const Fieldset = memo(
197
197
< div
198
198
className = { fr . cx ( "fr-messages-group" ) }
199
199
id = { messagesWrapperId }
200
- aria-live = " assertive"
200
+ aria-live = { state === "error" ? " assertive" : undefined }
201
201
>
202
202
{ stateRelatedMessage !== undefined && (
203
203
< p
204
- id = { ( ( ) => {
205
- switch ( state ) {
206
- case "error" :
207
- return errorDescId ;
208
- case "success" :
209
- return successDescId ;
210
- }
211
- } ) ( ) }
204
+ id = { messageId }
212
205
className = { fr . cx (
213
206
"fr-message" ,
214
207
( ( ) => {
You can’t perform that action at this time.
0 commit comments