Merge pull request #5894 from consuldemocracy/critical_axe_issues

Fix Axe accessibility issues with critical severity
This commit is contained in:
Javi Martín
2025-04-02 14:15:55 +02:00
committed by GitHub
13 changed files with 67 additions and 86 deletions

View File

@@ -0,0 +1,21 @@
(function() {
"use strict";
App.AdminDashboardActionsForm = {
initialize: function() {
$("input[name='dashboard_action[action_type]']").on({
change: function() {
switch ($(this).val()) {
case "proposed_action":
$("#request_to_administrators").hide();
$("#short_description").hide();
break;
case "resource":
$("#request_to_administrators").show();
$("#short_description").show();
}
}
}).filter("[checked]").trigger("change");
}
};
}).call(this);

View File

@@ -169,6 +169,7 @@ var initialize_modules = function() {
App.ColumnsSelector.initialize();
}
App.AdminBudgetsWizardCreationStep.initialize();
App.AdminDashboardActionsForm.initialize();
App.AdminMachineLearningScripts.initialize();
App.AdminPollShiftsForm.initialize();
App.AdminTenantsForm.initialize();

View File

@@ -1,50 +1,8 @@
.budget-group-switcher {
margin-bottom: $line-height;
p {
p,
ul {
margin-bottom: 0;
}
> .menu > li {
> button {
align-items: center;
border: $admin-border;
border-radius: $button-radius;
display: inline-flex;
padding: rem-calc(11) rem-calc(16);
&:active {
color: inherit;
}
&::after {
@include css-triangle($dropdownmenu-arrow-size, currentcolor, down);
margin-left: 0.2em;
}
}
}
.menu.is-dropdown-submenu {
margin: 0;
min-width: 100%;
padding: 0;
li {
margin-bottom: 0;
}
a {
cursor: default;
padding: rem-calc(11) rem-calc(16);
width: 100%;
&:focus,
&:hover {
@include brand-background;
@include no-outline;
text-decoration: none;
}
}
}
}

View File

@@ -2,20 +2,10 @@
<% if other_groups.one? %>
<p>
<%= currently_showing_text %>
<%= link_to t("admin.budget_headings.group_switcher.the_other_group", group: other_groups.first.name),
headings_path(other_groups.first) %>
<%= link_to_group(other_groups.first) %>
</p>
<% else %>
<p><%= currently_showing_text %></p>
<ul class="dropdown menu" data-dropdown-menu data-disable-hover="true" data-click-open="true">
<li class="has-submenu">
<button type="button"><%= t("admin.budget_headings.group_switcher.different_group") %></button>
<ul class="menu" data-submenu>
<% other_groups.each do |other_group| %>
<li><%= link_to other_group.name, headings_path(other_group) %></li>
<% end %>
</ul>
</li>
</ul>
<%= link_list(*other_groups.map { |group| link_to_group(group) }) %>
<% end %>
</div>

View File

@@ -1,5 +1,6 @@
class Admin::BudgetsWizard::Headings::GroupSwitcherComponent < ApplicationComponent
attr_reader :group
use_helpers :link_list
def initialize(group)
@group = group
@@ -26,4 +27,12 @@ class Admin::BudgetsWizard::Headings::GroupSwitcherComponent < ApplicationCompon
def currently_showing_text
sanitize(t("admin.budget_headings.group_switcher.currently_showing", group: group.name))
end
def link_to_group(group)
link_to(link_to_group_text(group), headings_path(group))
end
def link_to_group_text(group)
sanitize(t("admin.budget_headings.group_switcher.the_other_group", group: tag.strong(group.name)))
end
end

View File

@@ -8,8 +8,4 @@ module Admin::ProposalDashboardActionsHelper
def default_actions
%w[polls email poster]
end
def css_for_resource(action)
"hide" if action == "proposed_action"
end
end

View File

@@ -5,9 +5,7 @@
<%= f.label :action_type %>
<% ::Dashboard::Action.action_types.keys.each do |action_type_value| %>
<span class="margin-right">
<%= f.radio_button :action_type,
action_type_value,
data: { toggle: "request_to_administrators short_description" } %>
<%= f.radio_button :action_type, action_type_value %>
</span>
<% end %>
</div>
@@ -16,9 +14,7 @@
<%= f.check_box :active %>
</div>
<div id="request_to_administrators"
class="small-12 column margin-bottom <%= css_for_resource(@dashboard_action.action_type) %>"
data-toggler=".hide">
<div id="request_to_administrators" class="small-12 column margin-bottom">
<%= f.check_box :request_to_administrators %>
</div>
@@ -28,7 +24,7 @@
<div class="small-12 column">
<%= f.text_field :title %>
<div id="short_description" class="hide">
<div id="short_description">
<%= f.text_field :short_description %>
</div>

View File

@@ -1,9 +1,9 @@
<h2><%= t("admin.menu.site_customization.information_texts") %></h2>
<div class="tabs-content" data-tabs-content="information-texts-tabs" role="tablist">
<%= render "tabs" %>
<%= render "tabs" %>
<div class="tabs-panel is-active" role="tab">
<div class="tabs-content" data-tabs-content="information-texts-tabs">
<div class="tabs-panel is-active">
<%= render Admin::SiteCustomization::InformationTexts::FormComponent.new([@content]) %>
</div>
</div>

View File

@@ -212,7 +212,6 @@ en:
submit: "Save heading"
group_switcher:
currently_showing: "Showing headings from the <strong>%{group}</strong> group."
different_group: "Manage headings from a different group"
the_other_group: "Manage headings from the %{group} group."
index:
back: "Go back to groups"

View File

@@ -212,7 +212,6 @@ es:
submit: "Guardar partida"
group_switcher:
currently_showing: "Mostrando las partidas del grupo <strong>%{group}</strong>."
different_group: "Ir a partidas de otro grupo"
the_other_group: "Ir a partidas del grupo %{group}."
index:
back: "Volver a grupos"

View File

@@ -30,11 +30,14 @@ describe Admin::BudgetsWizard::Headings::GroupSwitcherComponent do
render_inline Admin::BudgetsWizard::Headings::GroupSwitcherComponent.new(group)
expect(page).to have_content "Showing headings from the Parks group"
expect(page).to have_button "Manage headings from a different group"
page.find("button + ul") do |list|
expect(list).to have_link "Recreation"
expect(list).to have_link "Entertainment"
page.find("ul") do |list|
expect(list).to have_css "li", count: 2
expect(list).to have_link count: 2
expect(list).to have_link "Manage headings from the Recreation group."
expect(list).to have_link "Manage headings from the Entertainment group."
expect(list).to have_css "strong", exact_text: "Recreation"
expect(list).to have_css "strong", exact_text: "Entertainment"
end
end
end

View File

@@ -35,8 +35,7 @@ describe "Budgets wizard, headings step", :admin do
expect(page).not_to have_link "Health"
click_button "Manage headings from a different group"
click_link "Health"
click_link "Manage headings from the Health group."
within(".heading") do
expect(page).to have_content "Hospitals"

View File

@@ -73,14 +73,24 @@ describe "Admin dashboard actions", :admin do
end
scenario "Updates the action" do
fill_in "dashboard_action_title", with: "Great action!"
expect(page).to have_checked_field "Proposed action"
expect(page).to have_unchecked_field "Resource"
expect(page).not_to have_field "Short description"
expect(page).not_to have_field "Include in the resource a button to " \
"request the resource from administrators"
choose "Resource"
check "Include in the resource a button to request the resource from administrators"
fill_in "Title", with: "Great action!"
fill_in "Short description", with: "And awesome too!"
click_button "Save"
expect(page).to have_content "Great action!"
end
scenario "Renders edit form in case data is invalid" do
fill_in "dashboard_action_title", with: "x"
fill_in "Title", with: "x"
click_button "Save"
expect(page).to have_content("error prevented this Dashboard/Action from being saved.")
end
@@ -89,11 +99,9 @@ describe "Admin dashboard actions", :admin do
context "when destroying an action" do
let!(:action) { create(:dashboard_action) }
before do
visit admin_dashboard_actions_path
end
scenario "deletes the action" do
visit admin_dashboard_actions_path
accept_confirm("Are you sure? This action will delete \"#{action.title}\" and can't be undone.") do
click_button "Delete"
end
@@ -101,8 +109,10 @@ describe "Admin dashboard actions", :admin do
expect(page).not_to have_content(action.title)
end
scenario "can not delete actions that have been executed" do
_executed_action = create(:dashboard_executed_action, action: action)
scenario "cannot delete actions that have been executed" do
create(:dashboard_executed_action, action: action)
visit admin_dashboard_actions_path
accept_confirm("Are you sure? This action will delete \"#{action.title}\" and can't be undone.") do
click_button "Delete"