Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: radio field accessibility #3666

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/avo/fields/radio_field/edit_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div class="flex flex-col gap-2">
<% @field.options.each do |key, value| %>
<div>
<%= form.radio_button @field.id, key %>
<%= form.label @field.id, value, value: value %>
<%= form.radio_button @field.id, key, checked: (@field.value.to_s == key.to_s) %>
<%= form.label @field.id, value, value: key %>
</div>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/app/avo/actions/sub/dummy_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Avo::Actions::Sub::DummyAction < Avo::BaseAction
end

def fields
field :size, as: :radio, options: {small: "Small Option", medium: "Medium Option", large: "Large Option"}
field :size, as: :radio, options: {small: "Small Option", medium: "Medium Option", large: "Large Option"}, default: :medium
TestBuddy.hi("Dummy action fields")
field :keep_modal_open, as: :boolean
field :persistent_text, as: :text
Expand Down
5 changes: 5 additions & 0 deletions spec/features/avo/radio_field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@

expect(page).to have_text("Small Option")
expect(page).to have_text("Medium Option")
expect(page).to have_checked_field("fields_size_medium")
expect(page).to have_text("Large Option")

find("label[for='fields_size_large']").click
expect(page).not_to have_checked_field("fields_size_medium")
expect(page).to have_checked_field("fields_size_large")
end
end
end
Loading