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.
This commit is contained in:
Javi Martín
2025-04-02 15:54:24 +02:00
parent 9308189a00
commit c6f1974c45
2 changed files with 6 additions and 7 deletions

View File

@@ -3,8 +3,7 @@
<div class="small-12 medium-9 column"> <div class="small-12 medium-9 column">
<%= f.translatable_fields do |translations_form| %> <%= f.translatable_fields do |translations_form| %>
<%= translations_form.text_field :value, <%= translations_form.text_field :value,
placeholder: t("admin.legislation.questions.form.value_placeholder"), label: t("admin.legislation.questions.form.value_placeholder") %>
label: false %>
<% end %> <% end %>
</div> </div>

View File

@@ -107,7 +107,7 @@ describe "Admin legislation questions", :admin do
create(:legislation_question_option, question: question, value: "Original") create(:legislation_question_option, question: question, value: "Original")
visit edit_question_url visit edit_question_url
find("#nested_question_options input").set("Changed") fill_in "Add a closed answer", with: "Changed"
click_button "Save changes" click_button "Save changes"
expect(page).to have_content "Question updated successfully" expect(page).to have_content "Question updated successfully"
@@ -154,11 +154,11 @@ describe "Admin legislation questions", :admin do
click_link "Add option" 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" 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" click_button "Save changes"
@@ -180,11 +180,11 @@ describe "Admin legislation questions", :admin do
click_link "Add option" 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" 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" click_button "Save changes"