Skip to content

Commit ad21a76

Browse files
authored
Fix a11y issues for facet icons and OpenIndexMaps previews (#344)
* Fix a11y issues for facet icons and OpenIndexMaps previews * Add a11y labeling for OpenIndexMaps popup links * Narrow OpenIndexMaps a11y fix to popup runtime patch * Use aria-label for selected facet remove links * Demote advanced search constraint label from heading * Fix standardrb issues Codex missed again
1 parent a55fab6 commit ad21a76

6 files changed

Lines changed: 71 additions & 1 deletion

File tree

app/assets/javascripts/geoblacklight.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//= require ./uwm/modules/results
1919
//= require geoblacklight/modules/svg_tooltips
2020
//= require geoblacklight/modules/util
21+
//= require ./geoblacklight/modules/util_a11y_patch
2122

2223
//= require geoblacklight/downloaders
2324
//= require leaflet-iiif
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*global GeoBlacklight */
2+
3+
(function() {
4+
if (!GeoBlacklight || !GeoBlacklight.Util || !GeoBlacklight.Util.indexMapTemplate) {
5+
return;
6+
}
7+
8+
function websiteLinkLabel(data) {
9+
if (data && data.title) return "Open website for " + data.title;
10+
if (data && data.label) return "Open website for " + data.label;
11+
return "Open website";
12+
}
13+
14+
function addIndexMapImageAccessibility(html, data) {
15+
var container = document.createElement("div");
16+
container.innerHTML = html;
17+
18+
Array.prototype.forEach.call(container.querySelectorAll(".index-map-info img"), function(image) {
19+
image.setAttribute("alt", "");
20+
21+
var link = image.closest("a");
22+
if (!link) return;
23+
24+
if (!link.getAttribute("aria-label")) {
25+
link.setAttribute("aria-label", websiteLinkLabel(data));
26+
}
27+
});
28+
29+
return container.innerHTML;
30+
}
31+
32+
var originalIndexMapTemplate = GeoBlacklight.Util.indexMapTemplate;
33+
34+
GeoBlacklight.Util.indexMapTemplate = function(data, cb) {
35+
return originalIndexMapTemplate.call(this, data, function(html) {
36+
cb(addIndexMapImageAccessibility(html, data));
37+
});
38+
};
39+
}());

app/assets/stylesheets/modules/_accordions.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
text-rendering: auto;
33
font: var(--fa-font-solid);
44
-webkit-font-smoothing: antialiased;
5+
color: currentColor;
56
font-size: 1rem;
67
line-height: 1;
78
position: absolute;
@@ -17,4 +18,4 @@
1718
transform: none;
1819
transition: none;
1920
content: "\F0FE";
20-
}
21+
}

app/assets/stylesheets/uwm.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787
color: $black !important;
8888
}
8989

90+
.facet-values .remove-icon {
91+
color: $black !important;
92+
}
93+
9094
// Results pagniation contrast fix for active page
9195

9296
.pagination .page-item.active .page-link {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="inclusive_or card card-body bg-light mb-3">
2+
<p class="mb-2 fw-bold"><%= t('blacklight.advanced_search.any_of') %></p>
3+
<ul class="list-unstyled facet-values">
4+
<%= helpers.render(Blacklight::FacetItemComponent.with_collection(presenters.to_a)) %>
5+
</ul>
6+
</div>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
Rails.application.config.to_prepare do
4+
Blacklight::FacetItemComponent.class_eval do
5+
def render_selected_facet_value
6+
tag.span(class: "facet-label") do
7+
tag.span(label, class: "selected") +
8+
link_to(
9+
href,
10+
class: "remove",
11+
rel: "nofollow",
12+
aria: {label: helpers.t(:"blacklight.search.facets.selected.remove")}
13+
) do
14+
tag.span("✖", class: "remove-icon", aria: {hidden: true})
15+
end
16+
end + render_facet_count(classes: ["selected"])
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)