From 6e88fc906b3af6f96df4ff620de85277ba1aea54 Mon Sep 17 00:00:00 2001 From: Tessa Kelly Date: Thu, 9 Dec 2021 13:17:29 -0800 Subject: [PATCH] Use a list for the aria-controls elements --- src/Nri/Ui/RadioButton/V3.elm | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Nri/Ui/RadioButton/V3.elm b/src/Nri/Ui/RadioButton/V3.elm index 71f69f45..dcef373c 100644 --- a/src/Nri/Ui/RadioButton/V3.elm +++ b/src/Nri/Ui/RadioButton/V3.elm @@ -301,18 +301,19 @@ view { label, name, value, valueToString, selectedValue } attributes = |> Maybe.withDefault True |> not - ( disclosureId, disclosureElement ) = + ( disclosureIds, disclosureElements ) = case ( config.disclosedContent, isChecked ) of ( [], _ ) -> - ( Nothing, text "" ) + ( [], [] ) ( _, False ) -> - ( Nothing, text "" ) + ( [], [] ) - ( (_ :: _) as childNodes, True ) -> - ( Just (idValue ++ "-disclosure-content") - , span [ Attributes.id (idValue ++ "-disclosure-content") ] - childNodes + ( _, True ) -> + ( List.indexedMap + (\index _ -> (idValue ++ "-disclosure-content-") ++ String.fromInt index) + config.disclosedContent + , config.disclosedContent ) isInError = @@ -338,7 +339,7 @@ view { label, name, value, valueToString, selectedValue } attributes = , Css.batch config.containerCss ] ] - [ radio name + ([ radio name stringValue isChecked ([ Attributes.id idValue @@ -351,7 +352,7 @@ view { label, name, value, valueToString, selectedValue } attributes = _ -> Extra.none , class "Nri-RadioButton-HiddenRadioInput" - , maybeAttr Aria.controls disclosureId + , Attributes.attribute "aria-controls" (String.join " " disclosureIds) , css [ position absolute , top (px 4) @@ -372,7 +373,7 @@ view { label, name, value, valueToString, selectedValue } attributes = ] ++ List.map (Attributes.map never) config.custom ) - , Html.label + , Html.label [ for idValue , classList [ ( "Nri-RadioButton-RadioButton", True ) @@ -448,9 +449,10 @@ view { label, name, value, valueToString, selectedValue } attributes = text "" ] ] - , disclosureElement - , InputErrorAndGuidanceInternal.view idValue config - ] + , InputErrorAndGuidanceInternal.view idValue config + ] + ++ disclosureElements + ) premiumPennant : msg -> Html msg