File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ export const Fieldset = memo(
98
98
99
99
const errorDescId = `${ id } -desc-error` ;
100
100
const successDescId = `${ id } -desc-valid` ;
101
+ const infoDescId = `${ id } -desc-info` ;
101
102
const messagesWrapperId = `${ id } -messages` ;
102
103
103
104
const radioName = ( function useClosure ( ) {
@@ -148,6 +149,17 @@ export const Fieldset = memo(
148
149
return renderOption ( { option : options [ 0 ] , i : undefined } ) ;
149
150
}
150
151
152
+ const messageId = ( ( ) => {
153
+ switch ( state ) {
154
+ case "error" :
155
+ return errorDescId ;
156
+ case "success" :
157
+ return successDescId ;
158
+ case "info" :
159
+ return infoDescId ;
160
+ }
161
+ } ) ( ) ;
162
+
151
163
return (
152
164
< fieldset
153
165
id = { id }
@@ -184,6 +196,7 @@ export const Fieldset = memo(
184
196
fr . cx ( "fr-fieldset__legend" , "fr-text--regular" ) ,
185
197
classes . legend
186
198
) }
199
+ aria-describedby = { messageId }
187
200
>
188
201
{ legend }
189
202
{ hintText !== undefined && (
@@ -197,18 +210,11 @@ export const Fieldset = memo(
197
210
< div
198
211
className = { fr . cx ( "fr-messages-group" ) }
199
212
id = { messagesWrapperId }
200
- aria-live = " assertive"
213
+ aria-live = { state === "error" ? " assertive" : undefined }
201
214
>
202
215
{ stateRelatedMessage !== undefined && (
203
216
< p
204
- id = { ( ( ) => {
205
- switch ( state ) {
206
- case "error" :
207
- return errorDescId ;
208
- case "success" :
209
- return successDescId ;
210
- }
211
- } ) ( ) }
217
+ id = { messageId }
212
218
className = { fr . cx (
213
219
"fr-message" ,
214
220
( ( ) => {
You can’t perform that action at this time.
0 commit comments