From acaab47ac49699483c930efbc61a1fae58988fa9 Mon Sep 17 00:00:00 2001 From: Laura Ghiorghisor Date: Tue, 19 Dec 2023 11:02:40 +0000 Subject: [PATCH 1/2] Improve accessibility of search results Part of fixes emerging from the accessibility review: > Add an aria-label to better identify the search results. > Make the cells in the first column of the search results table into headers --- .../admin/editions/_search_results.html.erb | 1 + app/views/admin/editions/index.html.erb | 2 +- .../_search_results.html.erb | 1 + .../shared/_featurable_editions.html.erb | 2 +- .../_search_results.html.erb | 1 + .../statistics_announcements/index.html.erb | 2 +- .../admin/editions_controller_test.rb | 20 +++++++++---------- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/views/admin/editions/_search_results.html.erb b/app/views/admin/editions/_search_results.html.erb index 542d507757f..16e0decb48a 100644 --- a/app/views/admin/editions/_search_results.html.erb +++ b/app/views/admin/editions/_search_results.html.erb @@ -46,6 +46,7 @@ }, ] end, + first_cell_is_header: true, } %> diff --git a/app/views/admin/editions/index.html.erb b/app/views/admin/editions/index.html.erb index f682a248976..2923e735103 100644 --- a/app/views/admin/editions/index.html.erb +++ b/app/views/admin/editions/index.html.erb @@ -7,7 +7,7 @@ <%= render "filter_options", filter_action: admin_editions_path %>
-
+
<%= render "search_results", filter: @filter, paginator: @filter.editions, show_export: true %>
diff --git a/app/views/admin/featurable_editions/_search_results.html.erb b/app/views/admin/featurable_editions/_search_results.html.erb index a2d7bb0d7ea..4e0eb797284 100644 --- a/app/views/admin/featurable_editions/_search_results.html.erb +++ b/app/views/admin/featurable_editions/_search_results.html.erb @@ -39,6 +39,7 @@ }, ] end, + first_cell_is_header: true, } %> <%= paginate(paginator, anchor: anchor, theme: "govuk_paginator") %> diff --git a/app/views/admin/shared/_featurable_editions.html.erb b/app/views/admin/shared/_featurable_editions.html.erb index f5e65889190..9f85b17a786 100644 --- a/app/views/admin/shared/_featurable_editions.html.erb +++ b/app/views/admin/shared/_featurable_editions.html.erb @@ -8,7 +8,7 @@ <%= render "admin/editions/filter_options", filter_by:, filter_action:, anchor: %>
-
+
<%= render "admin/featurable_editions/search_results", featurable_editions:, paginator:, anchor:, feature_path: %>
diff --git a/app/views/admin/statistics_announcements/_search_results.html.erb b/app/views/admin/statistics_announcements/_search_results.html.erb index 73c26e69049..06fa5764697 100644 --- a/app/views/admin/statistics_announcements/_search_results.html.erb +++ b/app/views/admin/statistics_announcements/_search_results.html.erb @@ -49,6 +49,7 @@ }, ] end, + first_cell_is_header: true, } %>
diff --git a/app/views/admin/statistics_announcements/index.html.erb b/app/views/admin/statistics_announcements/index.html.erb index 8a8ad05202d..efc05791c32 100644 --- a/app/views/admin/statistics_announcements/index.html.erb +++ b/app/views/admin/statistics_announcements/index.html.erb @@ -28,7 +28,7 @@ <%= render "filter_options" %>
-
+
<%= render "search_results", filter: @filter, paginator: @statistics_announcements, show_export: true %>
diff --git a/test/functional/admin/editions_controller_test.rb b/test/functional/admin/editions_controller_test.rb index 9e1e183e181..c0a00a4534f 100644 --- a/test/functional/admin/editions_controller_test.rb +++ b/test/functional/admin/editions_controller_test.rb @@ -164,7 +164,7 @@ class Admin::EditionsControllerTest < ActionController::TestCase get :index, params: { state: :published, type: :publication } assert_select ".govuk-table__row" do - assert_select ".govuk-table__cell:nth-child(1)", text: publication.title + assert_select ".govuk-table__header:nth-child(1)", text: publication.title assert_select ".govuk-table__cell:nth-child(3)", text: "Published" end end @@ -174,7 +174,7 @@ class Admin::EditionsControllerTest < ActionController::TestCase get :index, params: { state: :published, type: :publication } assert_select ".govuk-table__row" do - assert_select ".govuk-table__cell:nth-child(1)", text: publication.title + assert_select ".govuk-table__header:nth-child(1)", text: publication.title assert_select ".govuk-table__cell:nth-child(3)", text: "Force published" end end @@ -184,7 +184,7 @@ class Admin::EditionsControllerTest < ActionController::TestCase get :index, params: { state: :force_published, type: :publication } assert_select ".govuk-table__row" do - assert_select ".govuk-table__cell:nth-child(1)", text: publication.title + assert_select ".govuk-table__header:nth-child(1)", text: publication.title assert_select ".govuk-table__cell:nth-child(3)", text: "Force published" end end @@ -198,25 +198,25 @@ class Admin::EditionsControllerTest < ActionController::TestCase get :index, params: { state: :active } assert_select ".govuk-table__row" do - assert_select ".govuk-table__cell:nth-child(1)", text: draft_edition.title do |cell| + assert_select ".govuk-table__header:nth-child(1)", text: draft_edition.title do |cell| cell.first.parent.xpath("td[3]").text.strip == "Draft" end end assert_select ".govuk-table__row" do - assert_select ".govuk-table__cell:nth-child(1)", text: submitted_edition.title do |cell| + assert_select ".govuk-table__header:nth-child(1)", text: submitted_edition.title do |cell| cell.first.parent.xpath("td[3]").text.strip == "Submitted" end end assert_select ".govuk-table__row" do - assert_select ".govuk-table__cell:nth-child(1)", text: rejected_edition.title do |cell| + assert_select ".govuk-table__header:nth-child(1)", text: rejected_edition.title do |cell| cell.first.parent.xpath("td[3]").text.strip == "Rejected" end end assert_select ".govuk-table__row" do - assert_select ".govuk-table__cell:nth-child(1)", text: published_edition.title do |cell| + assert_select ".govuk-table__header:nth-child(1)", text: published_edition.title do |cell| cell.first.parent.xpath("td[3]").text.strip == "Published" end end @@ -236,9 +236,9 @@ class Admin::EditionsControllerTest < ActionController::TestCase get :index, params: { state: :active } accessible.each do |edition| - assert_select ".govuk-table__cell:nth-child(1)", text: edition.title + assert_select ".govuk-table__header:nth-child(1)", text: edition.title end - refute_select ".govuk-table__cell:nth-child(1)", text: inaccessible.title + refute_select ".govuk-table__header:nth-child(1)", text: inaccessible.title end view_test "index should indicate the protected status of limited access editions which I do have access to" do @@ -249,7 +249,7 @@ class Admin::EditionsControllerTest < ActionController::TestCase get :index, params: { state: :active } assert_select ".govuk-table__row" do - assert_select ".govuk-table__cell:nth-child(1)", text: publication.title + assert_select ".govuk-table__header:nth-child(1)", text: publication.title assert_select ".govuk-table__cell:nth-child(3)", text: "Draft Limited access" end end From dc590ccea76d4d1e0ad10a52fce886e8ed325f0e Mon Sep 17 00:00:00 2001 From: Laura Ghiorghisor Date: Tue, 19 Dec 2023 17:56:20 +0000 Subject: [PATCH 2/2] Remove separator from editions search results --- app/views/admin/editions/_search_results.html.erb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/admin/editions/_search_results.html.erb b/app/views/admin/editions/_search_results.html.erb index 16e0decb48a..1d6e0cfdf38 100644 --- a/app/views/admin/editions/_search_results.html.erb +++ b/app/views/admin/editions/_search_results.html.erb @@ -6,8 +6,6 @@

<%= pluralize(number_with_delimiter(@filter.editions.total_count), "document") %>

<% end %> -
- <% if filter.editions.blank? %>

No documents found

<% else %>