Skip to content

Commit 11012bd

Browse files
committed
Improve accessibility of search form
Why these changes are being introduced: Accessibility testing revealed that the search button is difficult for screen reader users to locate, and that the `title` attribute for the keyword search input is not useful. Relevant ticket(s): * [GDT-318](https://mitlibraries.atlassian.net/browse/GDT-318) How this addresses that need: This changes the keyword `title` to 'keyword anywhere' and moves the search button to the bottom of the form, after all of the advanced search dropdowns. It also updates some corresponding CSS, including removing the `border-radius` override for the `btn` class, so the search button looks more like a button. Side effects of this change: Fixed margin/padding for results summary panel and mobile filter toggle. (This is unrelated to this change, but I noticed while testing out the changes that the spacing looked odd.)
1 parent 908462d commit 11012bd

File tree

5 files changed

+18
-25
lines changed

5 files changed

+18
-25
lines changed

app/assets/stylesheets/partials/_filters.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#filters {
2+
@media (max-width: $bp-screen-md) {
3+
margin-bottom: 1.2rem;
4+
}
25
details.filter-category {
36
position: relative;
47
margin-bottom: 0.5em;

app/assets/stylesheets/partials/_panels.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
}
112112
}
113113
.list-filter-summary {
114-
padding-top: 1rem;
114+
padding-top: 0.8rem;
115115
border-top: 1px solid $black;
116116
}
117117
.hd-search-summary {

app/assets/stylesheets/partials/_results.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.top-space {
2-
margin-top: 2.4rem;
2+
margin-top: 1.2rem;
3+
@media (min-width: $bp-screen-md) {
4+
margin-top: 2.4rem;
5+
}
36
}
47

58
.wrap-results {

app/assets/stylesheets/partials/_search.scss

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.basic-search {
77
background-color: #989898;
88
margin-bottom: 0rem;
9-
padding: 2.4rem 2rem 1rem 2.4rem;
9+
padding: 2.4rem 2rem 1.6rem 2rem;
1010

1111
details {
1212
&:first-of-type {
@@ -35,12 +35,7 @@
3535
width: 100%;
3636
margin-bottom: .8rem;
3737
padding: 6px 12px;
38-
39-
@media (min-width: $bp-screen-sm) {
40-
display: inline-block;
41-
width: 80%;
42-
margin-bottom: 0;
43-
}
38+
margin-bottom: 0;
4439
}
4540

4641
summary {
@@ -112,12 +107,9 @@
112107
}
113108

114109
.basic-search-submit {
115-
@media (min-width: $bp-screen-sm) {
116-
display: inline-block;
117-
width: 18%;
118-
}
110+
width: 150px;
111+
margin-top: 0.8rem;
119112
.btn {
120-
border-radius: 0;
121113
width: 100%;
122114
}
123115
}

app/views/search/_form.html.erb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
<%
2-
# Conditional input label depends on whether a search has already happened.
3-
label = "Search the MIT Libraries"
4-
if params[:q]
5-
label = "You searched for"
6-
end
7-
82
# Initial form setup is determined by the advanced parameter. Thereafter it is altered by javascript.
93
advanced_label = "Search by title, author, etc."
104
advanced_label_class = "closed"
@@ -34,12 +28,9 @@ end
3428
<form id="basic-search" class="form-horizontal basic-search" action="<%= results_path %>" method="get" role="search">
3529
<div class="form-group">
3630
<input id="basic-search-main" type="search"
37-
class="field field-text basic-search-input <%= "required" if search_required %>" name="q" title="<%= label %>"
38-
placeholder="Enter your search"
31+
class="field field-text basic-search-input <%= "required" if search_required %>" name="q"
32+
title="Keyword anywhere" placeholder="Enter your search"
3933
value="<%= params[:q] %>" <%= 'required="required" aria-required="true"' if search_required %>>
40-
<div class="basic-search-submit">
41-
<button type="submit" class="btn button-primary">Search</button>
42-
</div>
4334

4435
<% if Flipflop.enabled?(:gdt) %>
4536
<details id="geobox-search-panel" <%= "open" if params[:geobox] == "true" %>>
@@ -220,6 +211,10 @@ end
220211
</div>
221212
</details>
222213
</div>
214+
215+
<div class="basic-search-submit">
216+
<button type="submit" class="btn button-primary">Search</button>
217+
</div>
223218
</form>
224219

225220
<% if Flipflop.enabled?(:boolean_picker) %>

0 commit comments

Comments
 (0)