Skip to content

Commit

Permalink
Merge pull request #188 from MITLibraries/gdt-318-improve-form-a11y
Browse files Browse the repository at this point in the history
Improve accessibility of search form
  • Loading branch information
jazairi authored May 10, 2024
2 parents 98d08e5 + 11012bd commit 02269ec
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 25 deletions.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/partials/_filters.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#filters {
@media (max-width: $bp-screen-md) {
margin-bottom: 1.2rem;
}
details.filter-category {
position: relative;
margin-bottom: 0.5em;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/partials/_panels.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
}
}
.list-filter-summary {
padding-top: 1rem;
padding-top: 0.8rem;
border-top: 1px solid $black;
}
.hd-search-summary {
Expand Down
5 changes: 4 additions & 1 deletion app/assets/stylesheets/partials/_results.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.top-space {
margin-top: 2.4rem;
margin-top: 1.2rem;
@media (min-width: $bp-screen-md) {
margin-top: 2.4rem;
}
}

.wrap-results {
Expand Down
16 changes: 4 additions & 12 deletions app/assets/stylesheets/partials/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.basic-search {
background-color: #989898;
margin-bottom: 0rem;
padding: 2.4rem 2rem 1rem 2.4rem;
padding: 2.4rem 2rem 1.6rem 2rem;

details {
&:first-of-type {
Expand Down Expand Up @@ -35,12 +35,7 @@
width: 100%;
margin-bottom: .8rem;
padding: 6px 12px;

@media (min-width: $bp-screen-sm) {
display: inline-block;
width: 80%;
margin-bottom: 0;
}
margin-bottom: 0;
}

summary {
Expand Down Expand Up @@ -112,12 +107,9 @@
}

.basic-search-submit {
@media (min-width: $bp-screen-sm) {
display: inline-block;
width: 18%;
}
width: 150px;
margin-top: 0.8rem;
.btn {
border-radius: 0;
width: 100%;
}
}
Expand Down
17 changes: 6 additions & 11 deletions app/views/search/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<%
# Conditional input label depends on whether a search has already happened.
label = "Search the MIT Libraries"
if params[:q]
label = "You searched for"
end

# Initial form setup is determined by the advanced parameter. Thereafter it is altered by javascript.
advanced_label = "Search by title, author, etc."
advanced_label_class = "closed"
Expand Down Expand Up @@ -34,12 +28,9 @@ end
<form id="basic-search" class="form-horizontal basic-search" action="<%= results_path %>" method="get" role="search">
<div class="form-group">
<input id="basic-search-main" type="search"
class="field field-text basic-search-input <%= "required" if search_required %>" name="q" title="<%= label %>"
placeholder="Enter your search"
class="field field-text basic-search-input <%= "required" if search_required %>" name="q"
title="Keyword anywhere" placeholder="Enter your search"
value="<%= params[:q] %>" <%= 'required="required" aria-required="true"' if search_required %>>
<div class="basic-search-submit">
<button type="submit" class="btn button-primary">Search</button>
</div>

<% if Flipflop.enabled?(:gdt) %>
<details id="geobox-search-panel" <%= "open" if params[:geobox] == "true" %>>
Expand Down Expand Up @@ -220,6 +211,10 @@ end
</div>
</details>
</div>

<div class="basic-search-submit">
<button type="submit" class="btn button-primary">Search</button>
</div>
</form>

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

0 comments on commit 02269ec

Please sign in to comment.