Skip to content

A platform for community discussion. Free, open, simple.

UX: add name to wizard radios for keyboard nav (#37615)

Renato Atilioc54250a7e76f
diff --git a/frontend/discourse/app/static/wizard/components/fields/radio.gjs b/frontend/discourse/app/static/wizard/components/fields/radio.gjs
index 9f0f9ab1001..34cd6745184 100644
--- a/frontend/discourse/app/static/wizard/components/fields/radio.gjs
+++ b/frontend/discourse/app/static/wizard/components/fields/radio.gjs
@@ -46,6 +46,7 @@ export default class Radio extends Component {
>
<input
type="radio"
+ name={{@field.id}}
value={{choice.id}}
class="wizard-container__radio"
disabled={{choice.disabled}}
diff --git a/spec/system/wizard_spec.rb b/spec/system/wizard_spec.rb
index 581fda730ff..409be593829 100644
--- a/spec/system/wizard_spec.rb
+++ b/spec/system/wizard_spec.rb
@@ -82,5 +82,18 @@ describe "Wizard", type: :system do
".wizard-container__radio-choice[data-choice-id='#{choice_id}'].--selected",
)
end
+
+ it "keeps arrow key navigation within same radio group" do
+ wizard_page.go_to_step("setup")
+
+ login_required_field = wizard_page.find_field("radio", "login-required")
+ private_radio =
+ login_required_field.find("[data-choice-id='private'] input[type='radio']", visible: :all)
+
+ private_radio.click
+ private_radio.send_keys(:right)
+
+ expect(login_required_field).to have_css("input[type='radio']:focus", visible: :all)
+ end
end
end