Allow tags to be removed with the keyboard

We improved accessibility by overwriting the setIcon method in the library.
Now we render a button and add the aria-label attribute.
This commit is contained in:
taitus
2021-01-18 12:23:07 +01:00
parent fce844261a
commit 602b22edfd
7 changed files with 23 additions and 6 deletions

View File

@@ -18,6 +18,11 @@
} }
}; };
amsify_suggestags.setIcon = function() {
var remove_tag_text = $(".sdg-related-list-selector .input").data("remove-tag-text");
return '<button aria-label="' + remove_tag_text + '" class="remove-tag ' + this.classes.removeTag.substring(1) + '">&#10006;</button>';
};
amsify_suggestags._settings({ amsify_suggestags._settings({
suggestions: $(".sdg-related-list-selector .input").data("suggestions-list"), suggestions: $(".sdg-related-list-selector .input").data("suggestions-list"),
whiteList: true, whiteList: true,

View File

@@ -32,6 +32,14 @@
margin-top: $line-height / 2; margin-top: $line-height / 2;
} }
.remove-tag {
color: $white;
&:focus {
outline: $outline-focus;
}
}
h3 { h3 {
@include header-font-size(h4); @include header-font-size(h4);
} }

View File

@@ -12,7 +12,8 @@
class: "input", class: "input",
placeholder: t("sdg.related_list_selector.placeholder"), placeholder: t("sdg.related_list_selector.placeholder"),
hint: t("sdg.related_list_selector.hint"), hint: t("sdg.related_list_selector.hint"),
data: { "suggestions-list": sdg_related_suggestions } %> data: { "suggestions-list": sdg_related_suggestions,
"remove-tag-text": t("sdg.related_list_selector.remove_tag") } %>
</div> </div>
<div class="help-section callout primary hide"> <div class="help-section callout primary hide">

View File

@@ -438,3 +438,4 @@ en:
title: "Which SDGs and targets are aligned with my %{record}?" title: "Which SDGs and targets are aligned with my %{record}?"
hint: "You can introduce the code of a specific goal/target or a text to find one" hint: "You can introduce the code of a specific goal/target or a text to find one"
placeholder: "Write a goal or target code or description" placeholder: "Write a goal or target code or description"
remove_tag: "Remove"

View File

@@ -438,3 +438,4 @@ es:
title: "¿Qué ODS y metas se alinean con mi %{record}?" title: "¿Qué ODS y metas se alinean con mi %{record}?"
hint: "Puedes introducir el código de un objetivo/meta específico o un texto para encontrar uno" hint: "Puedes introducir el código de un objetivo/meta específico o un texto para encontrar uno"
placeholder: "Escribe las etiquetas que desees" placeholder: "Escribe las etiquetas que desees"
remove_tag: "Eliminar"

View File

@@ -46,5 +46,6 @@ Capybara.register_driver :headless_chrome do |app|
end end
Capybara.exact = true Capybara.exact = true
Capybara.enable_aria_label = true
OmniAuth.config.test_mode = true OmniAuth.config.test_mode = true

View File

@@ -219,11 +219,11 @@ describe "SDG Relations", :js do
visit sdg_management_edit_legislation_process_path(process) visit sdg_management_edit_legislation_process_path(process)
within "span[data-val='2']" do within "span[data-val='2']" do
find(".amsify-remove-tag").click click_button "Remove"
end end
within "span[data-val='3.3']" do within "span[data-val='3.3']" do
find(".amsify-remove-tag").click click_button "Remove"
end end
click_button "Update Process" click_button "Update Process"
@@ -334,13 +334,13 @@ describe "SDG Relations", :js do
visit sdg_management_edit_legislation_process_path(process) visit sdg_management_edit_legislation_process_path(process)
within "span[data-val='1']" do within "span[data-val='1']" do
find(".amsify-remove-tag").click click_button "Remove"
end end
expect(find("li[data-code='1']")["aria-checked"]).to eq "true" expect(find("li[data-code='1']")["aria-checked"]).to eq "true"
within "span[data-val='1.1']" do within "span[data-val='1.1']" do
find(".amsify-remove-tag").click click_button "Remove"
end end
expect(find("li[data-code='1']")["aria-checked"]).to eq "false" expect(find("li[data-code='1']")["aria-checked"]).to eq "false"
@@ -366,7 +366,7 @@ describe "SDG Relations", :js do
within(".help-section") { expect(page).to have_content "No Poverty" } within(".help-section") { expect(page).to have_content "No Poverty" }
within "span[data-val='1']" do within "span[data-val='1']" do
find(".amsify-remove-tag").click click_button "Remove"
end end
expect(page).not_to have_content "No Poverty" expect(page).not_to have_content "No Poverty"