wrap grey block with a button, not a div

This is so we can select the radio button when clicking anywhere in the
grey. So why not a <label>? Then the full contents of the disclosure
would be read out as the label content when picking options. That
content *describes* the radio button but it does not *label* it, and
should not be read out before "selected, n of m" and the rest of the
radio helper voiceover content.
This commit is contained in:
Alex Perkins 2021-11-21 09:16:34 -05:00
parent e0ef0ccc73
commit 5d86a5fa31

View File

@ -374,13 +374,24 @@ internalConfig label config eventsAndValues =
viewBlock : InternalConfig value msg -> Html msg
viewBlock config =
Html.div
let
onClick_ =
case ( config.onSelect, config.isDisabled ) of
( Just onSelect_, False ) ->
onClick (onSelect_ config.value)
_ ->
Attributes.none
in
button
[ id (config.id ++ "-container")
, classList [ ( "Nri-RadioButton-PremiumClass", config.showPennant ) ]
, onClick_
, css
[ position relative
, display Css.block
, Css.height (px 34)
, displayFlex
, border zero
, Css.minHeight (px 34)
, Css.width <| pct 100
, Css.backgroundColor Colors.gray96
, padding <| Css.px 20
@ -393,12 +404,7 @@ viewBlock config =
config.isChecked
[ id config.id
, Widget.disabled (config.isLocked || config.isDisabled)
, case ( config.onSelect, config.isDisabled ) of
( Just onSelect_, False ) ->
onClick (onSelect_ config.value)
_ ->
Attributes.none
, onClick_
, class "Nri-RadioButton-HiddenRadioInput"
, maybeAttr (Tuple.first >> Aria.controls) config.disclosureIdAndElement
, case config.describedByIds of