From c6f1974c45f6d54a15511fd6fa21a557e85112da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 2 Apr 2025 15:54:24 +0200 Subject: [PATCH] Use labels in nested option fields We were using a placeholder, which is way less accessible than a label. One issue here (which also happened before, but is now more obvious) is that, when adding several options, there will be many fields with the same label. Another issue is that, for some languages, we're using texts like "Add a closed answer", which might be confusing because we might be editing an existing answer. The proper solution would probably be using the text "Option 1", "Option 2", ... I'm not doing so right now because I'm not sure that's a good option and because changing the text would mean losing the existing translations. --- .../questions/_question_option_fields.html.erb | 3 +-- spec/system/admin/legislation/questions_spec.rb | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/views/admin/legislation/questions/_question_option_fields.html.erb b/app/views/admin/legislation/questions/_question_option_fields.html.erb index c610c298c..6e6b3080c 100644 --- a/app/views/admin/legislation/questions/_question_option_fields.html.erb +++ b/app/views/admin/legislation/questions/_question_option_fields.html.erb @@ -3,8 +3,7 @@
<%= f.translatable_fields do |translations_form| %> <%= translations_form.text_field :value, - placeholder: t("admin.legislation.questions.form.value_placeholder"), - label: false %> + label: t("admin.legislation.questions.form.value_placeholder") %> <% end %>
diff --git a/spec/system/admin/legislation/questions_spec.rb b/spec/system/admin/legislation/questions_spec.rb index 0573c7dcd..ad0376280 100644 --- a/spec/system/admin/legislation/questions_spec.rb +++ b/spec/system/admin/legislation/questions_spec.rb @@ -107,7 +107,7 @@ describe "Admin legislation questions", :admin do create(:legislation_question_option, question: question, value: "Original") visit edit_question_url - find("#nested_question_options input").set("Changed") + fill_in "Add a closed answer", with: "Changed" click_button "Save changes" expect(page).to have_content "Question updated successfully" @@ -154,11 +154,11 @@ describe "Admin legislation questions", :admin do click_link "Add option" - find("#nested_question_options input").set("Option 1") + fill_in "Add a closed answer", with: "Option 1" select "Español", from: "Current language" - find("#nested_question_options input").set("Opción 1") + fill_in "Add a closed answer", with: "Opción 1" click_button "Save changes" @@ -180,11 +180,11 @@ describe "Admin legislation questions", :admin do click_link "Add option" - find("#nested_question_options input").set("Opción 1") + fill_in "Add a closed answer", with: "Opción 1" select "English", from: "Current language" - find("#nested_question_options input").set("Option 1") + fill_in "Add a closed answer", with: "Option 1" click_button "Save changes"