From a14131e73b9e31ae706a18d9241083c1d4f401ed Mon Sep 17 00:00:00 2001
From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com>
Date: Tue, 21 Jan 2025 21:15:11 +0200
Subject: [PATCH] fix: radio field on actions & improve accessibility (#3600)
* fix: radio field on actions
* Update spec/features/avo/radio_field_spec.rb
---
.../fields/radio_field/edit_component.html.erb | 2 +-
spec/dummy/app/avo/actions/sub/dummy_action.rb | 1 +
spec/features/avo/radio_field_spec.rb | 16 ++++++++++++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/app/components/avo/fields/radio_field/edit_component.html.erb b/app/components/avo/fields/radio_field/edit_component.html.erb
index 46224729c..cd84ac731 100644
--- a/app/components/avo/fields/radio_field/edit_component.html.erb
+++ b/app/components/avo/fields/radio_field/edit_component.html.erb
@@ -3,7 +3,7 @@
<% @field.options.each do |key, value| %>
<%= form.radio_button @field.id, key %>
- <%= form.label @field.id, value: value %>
+ <%= form.label @field.id, value, value: value %>
<% end %>
diff --git a/spec/dummy/app/avo/actions/sub/dummy_action.rb b/spec/dummy/app/avo/actions/sub/dummy_action.rb
index c65de2b81..6f62505fa 100644
--- a/spec/dummy/app/avo/actions/sub/dummy_action.rb
+++ b/spec/dummy/app/avo/actions/sub/dummy_action.rb
@@ -13,6 +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"}
TestBuddy.hi("Dummy action fields")
field :keep_modal_open, as: :boolean
field :persistent_text, as: :text
diff --git a/spec/features/avo/radio_field_spec.rb b/spec/features/avo/radio_field_spec.rb
index 3a211f7cc..b8182deee 100644
--- a/spec/features/avo/radio_field_spec.rb
+++ b/spec/features/avo/radio_field_spec.rb
@@ -62,4 +62,20 @@
end
end
end
+
+ describe "on actions" do
+ it "display options" do
+ visit avo.resources_users_path
+
+ expect(page).not_to have_text("Small Option")
+ expect(page).not_to have_text("Medium Option")
+ expect(page).not_to have_text("Large Option")
+
+ open_panel_action(action_name: "Dummy action")
+
+ expect(page).to have_text("Small Option")
+ expect(page).to have_text("Medium Option")
+ expect(page).to have_text("Large Option")
+ end
+ end
end