Use a list for the aria-controls elements

This commit is contained in:
Tessa Kelly 2021-12-09 13:17:29 -08:00
parent 603deb90c7
commit 6e88fc906b

View File

@ -301,18 +301,19 @@ view { label, name, value, valueToString, selectedValue } attributes =
|> Maybe.withDefault True |> Maybe.withDefault True
|> not |> not
( disclosureId, disclosureElement ) = ( disclosureIds, disclosureElements ) =
case ( config.disclosedContent, isChecked ) of case ( config.disclosedContent, isChecked ) of
( [], _ ) -> ( [], _ ) ->
( Nothing, text "" ) ( [], [] )
( _, False ) -> ( _, False ) ->
( Nothing, text "" ) ( [], [] )
( (_ :: _) as childNodes, True ) -> ( _, True ) ->
( Just (idValue ++ "-disclosure-content") ( List.indexedMap
, span [ Attributes.id (idValue ++ "-disclosure-content") ] (\index _ -> (idValue ++ "-disclosure-content-") ++ String.fromInt index)
childNodes config.disclosedContent
, config.disclosedContent
) )
isInError = isInError =
@ -338,7 +339,7 @@ view { label, name, value, valueToString, selectedValue } attributes =
, Css.batch config.containerCss , Css.batch config.containerCss
] ]
] ]
[ radio name ([ radio name
stringValue stringValue
isChecked isChecked
([ Attributes.id idValue ([ Attributes.id idValue
@ -351,7 +352,7 @@ view { label, name, value, valueToString, selectedValue } attributes =
_ -> _ ->
Extra.none Extra.none
, class "Nri-RadioButton-HiddenRadioInput" , class "Nri-RadioButton-HiddenRadioInput"
, maybeAttr Aria.controls disclosureId , Attributes.attribute "aria-controls" (String.join " " disclosureIds)
, css , css
[ position absolute [ position absolute
, top (px 4) , top (px 4)
@ -372,7 +373,7 @@ view { label, name, value, valueToString, selectedValue } attributes =
] ]
++ List.map (Attributes.map never) config.custom ++ List.map (Attributes.map never) config.custom
) )
, Html.label , Html.label
[ for idValue [ for idValue
, classList , classList
[ ( "Nri-RadioButton-RadioButton", True ) [ ( "Nri-RadioButton-RadioButton", True )
@ -448,9 +449,10 @@ view { label, name, value, valueToString, selectedValue } attributes =
text "" text ""
] ]
] ]
, disclosureElement , InputErrorAndGuidanceInternal.view idValue config
, InputErrorAndGuidanceInternal.view idValue config ]
] ++ disclosureElements
)
premiumPennant : msg -> Html msg premiumPennant : msg -> Html msg