Skip to content

Commit

Permalink
Add a label for the search input
Browse files Browse the repository at this point in the history
- Properly label the input, to improve accessibility, but visually hide it to
  maintain the design, which uses a placeholder to indicate use
- Uses the hide content technique from The Accessibility Project:
  http://a11yproject.com/posts/how-to-hide-content/
- Fixes #415
  • Loading branch information
Tyson Gach committed Jan 18, 2016
1 parent 6783d20 commit 032c7ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/administrate/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
@import "library/**/*";
@import "base/**/*";
@import "components/**/*";
@import "utilities/**/*";
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.visually-hidden {
@include size(1px);
border: 0;
clip: rect(1px, 1px, 1px, 1px);
overflow: hidden;
padding: 0;
position: absolute;
}
2 changes: 2 additions & 0 deletions app/views/administrate/application/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ It renders the `_table` partial to display details about the resources.
<span class="search__icon">
<%= inline_svg "administrate/search.svg" %>
</span>
<label class="visually-hidden" for="search-input">Search</label>
<input
type="text"
name="search"
class="search__input"
id="search-input"
placeholder="Search"
value="<%= search_term %>"
/>
Expand Down

0 comments on commit 032c7ee

Please sign in to comment.