Skip to content

Commit 2d04743

Browse files
committed
Add more skip links for ease of tab navigation
Why these changes are being introduced: This application has many focusable elements, and it may be helpful to users navigating with keyboards or screen readers if we provide links to skip to different sections. Relevant ticket(s): * [GDT-161](https://mitlibraries.atlassian.net/browse/GDT-161) How this addresses that need: This adds the following skip links to the `_skip_links` partial: * All views: nav, search form * Results: results list, filter sidebar * Record: record metadata It also adds `.skip-link` rules to our SCSS, copied from the `#skip` rules in the style guide with two changes: * The `width: 0` rule has been removed in a step towards partial Safari support, as Safari will not focus on elements with this rule. * The color of skip links on focus is now white, as the current blue-on-black is a contrast error. Safari has a significant focus bug that Apple seems unlikely to fix. [This article](https://itnext.io/fixing-focus-for-safari-b5916fef1064) details the problem and provides a polyfill that solves it. As this bug likely affects all of our applications, we should incorporate that polyfill in the style guide. I've opened [ENGX-260](https://mitlibraries.atlassian.net/browse/ENGX-260) to do so. Side effects of this change: * Some IDs have been added to top-level elements to make them selectable. * While working on this, I realized that VoiceOver doesn't recognize the filter labels as disclosure triangles, so even when they are closed, it tabs through every available filter. I've fixed this in a subsequent commit. * There is an open question as to whether this is too many skip links. [WebAIM's guidance on skip links](https://webaim.org/techniques/skipnav/#multiple) suggests that one is optimal, but more than one may be necessary in some cases. Whether our use case necessitates them is somewhat unclear, as are the best practices for how many links to provide if you are providing multiple. I plan to discuss this further with Darcy in UX review. If we can't come to a decision, it would be a good question for DAS.
1 parent 2591906 commit 2d04743

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed

app/assets/stylesheets/partials/_shared.scss

+20
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,23 @@
3939
}
4040
}
4141
}
42+
43+
.skip-link {
44+
position: absolute;
45+
overflow: hidden;
46+
top: 0;
47+
left: 0;
48+
height: 0;
49+
color: $gray-l2;
50+
background-color: $black;
51+
border-bottom: 2px solid $success;
52+
53+
&:focus {
54+
position: relative;
55+
display: block;
56+
height: auto;
57+
color: $white;
58+
width: 100%;
59+
padding: 5px 2%;
60+
}
61+
}

app/views/layouts/_site_nav.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="wrap-outer-header-local layout-band">
22
<div class="wrap-header-local">
33
<div class="wrap-local-nav">
4-
<nav class="local-nav" aria-label="Main menu">
4+
<nav class="local-nav" id="main-menu" aria-label="Main menu">
55
<%= nav_link_to("Home", root_path) %>
66
<% if Flipflop.enabled?(:gdt) %>
77
<div class="wrap-gis-links">
+11-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
<a id="skip" class="sr sr-focusable" href="#content-main">Skip to main content</a>
1+
<a class="skip-link sr sr-focusable" href="#main-menu">Skip to main menu</a>
2+
<a class="skip-link sr sr-focusable" href="#basic-search">Skip to search form</a>
3+
<% if current_page?(results_path) %>
4+
<a class="skip-link sr sr-focusable" href="#results">Skip to results</a>
5+
<% if @filters.present? %>
6+
<a class="skip-link sr sr-focusable" href="#filters">Skip to search filters</a>
7+
<% end %>
8+
<% end %>
9+
<% if controller.controller_name == 'record' && controller.action_name == 'view' %>
10+
<a class="skip-link sr sr-focusable" href="#full-record">Skip to metadata</a>
11+
<% end %>

app/views/record/_record.html.erb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
<div class="gridband layout-3q1q wrap-full-record">
1+
<div id="full-record" class="gridband layout-3q1q wrap-full-record">
22
<div class="col3q box-content region full-record" data-region="Full record">
3-
43
<h2 class="record-title">
54
<span class="sr">Title: </span>
65
<% if @record['title'].present? %>

app/views/record/_record_geo.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="gridband layout-3q1q wrap-full-record">
1+
<div id="full-record" class="gridband layout-3q1q wrap-full-record">
22
<div class="col3q box-content region full-record" data-region="Full record">
33
<h2 class="record-title">
44
<span class="sr">Title: </span>

0 commit comments

Comments
 (0)