A platform for community discussion. Free, open, simple.
A11Y: make wizard radios accessible (#37064)
Krisfb4bbca93193
diff --git a/app/assets/stylesheets/wizard.scss b/app/assets/stylesheets/wizard.scssindex ed799b699fe..6b09384546e 100644--- a/app/assets/stylesheets/wizard.scss+++ b/app/assets/stylesheets/wizard.scss@@ -294,8 +294,12 @@ body.wizard {}&__radio {+ // these must be accessible in the DOM for accessibilty+ // so we can't use visibility: hidden or display: noneposition: absolute;- visibility: hidden;+ opacity: 0;+ width: 1px;+ height: 1px;}&__radio-choices {@@ -322,6 +326,13 @@ body.wizard {}}+ &:focus-within {+ .wizard-container__label {+ outline: 2px solid var(--d-input-focused-color);+ outline-offset: 2px;+ }+ }+.wizard-container__label {border-radius: 4px;border: 1px solid var(--primary-low-mid);diff --git a/spec/system/wizard_spec.rb b/spec/system/wizard_spec.rbindex d54aba3d1fc..581fda730ff 100644--- a/spec/system/wizard_spec.rb+++ b/spec/system/wizard_spec.rb@@ -64,5 +64,23 @@ describe "Wizard", type: :system doexpect(wizard_page).to be_on_step("setup")expect(page).to have_css(".wizard-container__field.text-title.invalid")end++ it "allows keyboard navigation of radio inputs" do+ wizard_page.go_to_step("setup")++ radio_field = wizard_page.find_field("radio", "login-required")+ first_radio = radio_field.find("input[type='radio']", match: :first, visible: :all)+ choice_id = first_radio[:value]++ page.execute_script("arguments[0].focus()", first_radio)++ expect(radio_field).to have_css(".wizard-container__radio-choice:focus-within")+ expect(page.evaluate_script("document.activeElement.type")).to eq("radio")++ first_radio.send_keys(:space)+ expect(radio_field).to have_css(+ ".wizard-container__radio-choice[data-choice-id='#{choice_id}'].--selected",+ )+ endendend