Use labels in officing results form

Back when we added all the missing labels (changes that we merged in
commit c34cab282), we forgot about fields which had placeholdes, since
Axe doesn't report an error when there are placeholders but there aren't
labels.

In this case, we were using an invalid <label> tag for the question
options, and <h3> tags as labels for the votes.

Using standard labels solves the issue.
This commit is contained in:
Javi Martín
2025-04-02 18:08:49 +02:00
parent 1632990838
commit 31f413de61
2 changed files with 16 additions and 16 deletions

View File

@@ -15,7 +15,7 @@
</div> </div>
<% question.question_options.each_with_index do |option, i| %> <% question.question_options.each_with_index do |option, i| %>
<div class="small-12 medium-6 large-3 column end"> <div class="small-12 medium-6 large-3 column end">
<label><%= option.title %></label> <%= label_tag "questions_#{question.id}_#{i}", option.title %>
<%= text_field_tag "questions[#{question.id}][#{i}]", answer_result_value(question.id, i), placeholder: "0" %> <%= text_field_tag "questions[#{question.id}][#{i}]", answer_result_value(question.id, i), placeholder: "0" %>
</div> </div>
<% end %> <% end %>
@@ -25,17 +25,17 @@
<div class="row"> <div class="row">
<div class="small-12 medium-6 large-3 column"> <div class="small-12 medium-6 large-3 column">
<h3><%= t("officing.results.new.ballots_white") %></h3> <%= label_tag :whites, t("officing.results.new.ballots_white") %>
<%= text_field_tag :whites, params[:whites].presence, placeholder: "0" %> <%= text_field_tag :whites, params[:whites].presence, placeholder: "0" %>
</div> </div>
<div class="small-12 medium-6 large-3 column end"> <div class="small-12 medium-6 large-3 column end">
<h3><%= t("officing.results.new.ballots_null") %></h3> <%= label_tag :nulls, t("officing.results.new.ballots_null") %>
<%= text_field_tag :nulls, params[:nulls].presence, placeholder: "0" %> <%= text_field_tag :nulls, params[:nulls].presence, placeholder: "0" %>
</div> </div>
<div class="small-12 medium-6 large-3 column end"> <div class="small-12 medium-6 large-3 column end">
<h3><%= t("officing.results.new.ballots_total") %></h3> <%= label_tag :total, t("officing.results.new.ballots_total") %>
<%= text_field_tag :total, params[:total].presence, placeholder: "0" %> <%= text_field_tag :total, params[:total].presence, placeholder: "0" %>
</div> </div>
</div> </div>

View File

@@ -59,15 +59,15 @@ describe "Officing Results", :with_frozen_time do
select booth.name, from: "Booth" select booth.name, from: "Booth"
fill_in "questions[#{question_1.id}][0]", with: "100" fill_in "Yes", with: "100"
fill_in "questions[#{question_1.id}][1]", with: "200" fill_in "No", with: "200"
fill_in "questions[#{question_2.id}][0]", with: "333" fill_in "Today", with: "333"
fill_in "questions[#{question_2.id}][1]", with: "444" fill_in "Tomorrow", with: "444"
fill_in "whites", with: "66" fill_in "Totally blank ballots", with: "66"
fill_in "nulls", with: "77" fill_in "Invalid ballots", with: "77"
fill_in "total", with: "88" fill_in "Valid ballots", with: "88"
click_button "Save" click_button "Save"
@@ -102,11 +102,11 @@ describe "Officing Results", :with_frozen_time do
booth_name = partial_result.booth_assignment.booth.name booth_name = partial_result.booth_assignment.booth.name
select booth_name, from: "Booth" select booth_name, from: "Booth"
fill_in "questions[#{question_1.id}][0]", with: "5555" fill_in "Yes", with: "5555"
fill_in "questions[#{question_1.id}][1]", with: "200" fill_in "No", with: "200"
fill_in "whites", with: "6" fill_in "Totally blank ballots", with: "6"
fill_in "nulls", with: "7" fill_in "Invalid ballots", with: "7"
fill_in "total", with: "8" fill_in "Valid ballots", with: "8"
click_button "Save" click_button "Save"