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(
9898
9999 const errorDescId = `${ id } -desc-error` ;
100100 const successDescId = `${ id } -desc-valid` ;
101+ const infoDescId = `${ id } -desc-info` ;
101102 const messagesWrapperId = `${ id } -messages` ;
102103
103104 const radioName = ( function useClosure ( ) {
@@ -148,6 +149,17 @@ export const Fieldset = memo(
148149 return renderOption ( { option : options [ 0 ] , i : undefined } ) ;
149150 }
150151
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+
151163 return (
152164 < fieldset
153165 id = { id }
@@ -184,6 +196,7 @@ export const Fieldset = memo(
184196 fr . cx ( "fr-fieldset__legend" , "fr-text--regular" ) ,
185197 classes . legend
186198 ) }
199+ aria-describedby = { messageId }
187200 >
188201 { legend }
189202 { hintText !== undefined && (
@@ -197,18 +210,11 @@ export const Fieldset = memo(
197210 < div
198211 className = { fr . cx ( "fr-messages-group" ) }
199212 id = { messagesWrapperId }
200- aria-live = " assertive"
213+ aria-live = { state === "error" ? " assertive" : undefined }
201214 >
202215 { stateRelatedMessage !== undefined && (
203216 < p
204- id = { ( ( ) => {
205- switch ( state ) {
206- case "error" :
207- return errorDescId ;
208- case "success" :
209- return successDescId ;
210- }
211- } ) ( ) }
217+ id = { messageId }
212218 className = { fr . cx (
213219 "fr-message" ,
214220 ( ( ) => {
You can’t perform that action at this time.
0 commit comments