Skip to content

Commit

Permalink
fix(a11y): Remove unnecessary aria-hidden attributes
Browse files Browse the repository at this point in the history
These attributes were present on elements that already have `display: none`, making these attributes redundant, or worse.
  • Loading branch information
Mitcheljager committed Jan 13, 2025
1 parent 88878f6 commit b993767
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
2 changes: 0 additions & 2 deletions app/javascript/src/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ function revealTab(target: string, parentElement: Element): void {
if (activeElement) {
activeElement.classList.remove("tabs-content--active")
activeElement.classList.remove("tabs-content--transitioning-out")
activeElement.ariaHidden = "true"
}

if (!targetElement) return

targetElement.classList.add("tabs-content--active")
targetElement.classList.add("tabs-content--transitioning-in")
targetElement.ariaHidden = "false"

resetCarouselInTab(targetElement)
}, 150)
Expand Down
10 changes: 5 additions & 5 deletions app/views/admin/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<% end %>
</div>

<div class="tabs-content" data-tab="notifications" aria-hidden="true">
<div class="tabs-content" data-tab="notifications">
<div class="well well--dark block">
<h4 class="mt-0">Send this user a notifcation</h4>

Expand All @@ -107,7 +107,7 @@
<% end %>
</div>

<div class="tabs-content" data-tab="badges" aria-hidden="true">
<div class="tabs-content" data-tab="badges">
<div class="well well--dark block">
<h4 class="mt-0">Badges</h4>

Expand Down Expand Up @@ -136,7 +136,7 @@
</div>
</div>

<div class="tabs-content" data-tab="posts" aria-hidden="true">
<div class="tabs-content" data-tab="posts">
<h3 class="mt-0">Posts by <%= @user.username %></h3>

<table class="w-auto">
Expand All @@ -152,7 +152,7 @@
</table>
</div>

<div class="tabs-content" data-tab="comments" aria-hidden="true">
<div class="tabs-content" data-tab="comments">
<h3 class="mt-0">Latest 20 comments</h3>

<% @user.comments.order(created_at: :desc).limit(20).each do |comment| %>
Expand All @@ -168,7 +168,7 @@
<% end %>
</div>

<div class="tabs-content" data-tab="activity" aria-hidden="true">
<div class="tabs-content" data-tab="activity">
<h3 class="mt-0">Latest 20 activity</h3>

<% @user.activities.order(created_at: :desc).limit(20).each do |activity| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/blocks/profile/_edit_blocks.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% active = params[:tab].present? && params[:tab] == "blocks" %>

<div class="tabs-content <%= "tabs-content--active" if active %>" data-tab="blocks" aria-hidden="<%= !active %>">
<div class="tabs-content <%= "tabs-content--active" if active %>" data-tab="blocks">
<h2 class="mt-1/1 mb-0">Blocks</h2>

<div data-role="blocks block-sortable">
Expand Down
2 changes: 1 addition & 1 deletion app/views/collections/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</div>
</div>

<div class="tabs-content" data-tab="codes" aria-hidden="true">
<div class="tabs-content" data-tab="codes">
<p>
<em>Select all codes that are part of this collection. Codes can only be in one collection.</em>
</p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/posts/_controls.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<% tabs.each do |tab| %>
<% active = tab == "workshop" %>
<div class="tabs-content <%= "tabs-content--active" if active %>" data-tab="<%= tab %>" aria-hidden="<%= !active %>">
<div class="tabs-content <%= "tabs-content--active" if active %>" data-tab="<%= tab %>">
<div class="controls">
<% @post.parsed_controls.each do |item| %>
<% next unless item["description"].present? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/posts/form/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<% tabs << "revision" if @post.persisted? %>

<% tabs.each_with_index do |tab, index| %>
<div class="tabs-content <%= "tabs-content--active" if index == 0 %>" data-tab="<%= tab %>" aria-hidden="<%= index > 0 %>">
<div class="tabs-content <%= "tabs-content--active" if index == 0 %>" data-tab="<%= tab %>">
<%= render "posts/form/tabs/#{ tab }", form: form %>

<hr class="mt-1/2 mb-1/2" />
Expand Down
6 changes: 3 additions & 3 deletions app/views/profiles/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= form_for @user, url: update_profile_path, remote: true do |form| %>
<div class="tabs-content <%= "tabs-content--active" unless params[:tab].present? && params[:tab] != "about-you" %>" data-tab="about-you" aria-hidden="<%= params[:tab].present? || (params[:tab].present? && params[:tab] != "about-you") %>">
<div class="tabs-content <%= "tabs-content--active" unless params[:tab].present? && params[:tab] != "about-you" %>" data-tab="about-you">
<h2 class="mt-1/1 mb-0">About you</h2>

<% if @user.verified? %>
Expand Down Expand Up @@ -48,7 +48,7 @@
<%= button_tag "Cancel", type: "button", class: "button button--secondary pr-1/1 pl-1/1", onclick: "location.search = '?tab=about-you'" %>
</div>

<div class="tabs-content <%= "tabs-content--active" if params[:tab].present? && params[:tab] == "images" %>" data-tab="images" aria-hidden="<%= params[:tab] != "images" %>">
<div class="tabs-content <%= "tabs-content--active" if params[:tab].present? && params[:tab] == "images" %>" data-tab="images">
<h2 class="mt-1/1 mb-0">Images</h2>

<div class="well well--dark block mt-1/2">
Expand Down Expand Up @@ -105,7 +105,7 @@
<%= button_tag "Cancel", type: "button", class: "button button--secondary pr-1/1 pl-1/1", onclick: "location.search = '?tab=images'" %>
</div>

<div class="tabs-content <%= "tabs-content--active" if params[:tab].present? && params[:tab] == "badges" %>" data-tab="badges" aria-hidden="<%= params[:tab] != "badges" %>">
<div class="tabs-content <%= "tabs-content--active" if params[:tab].present? && params[:tab] == "badges" %>" data-tab="badges">
<div class="well block mb-1/2 mt-1/2">
<h4 class="mt-0">Badges you've earned</h4>

Expand Down
6 changes: 3 additions & 3 deletions app/views/profiles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>

<% if @blocks.any? %>
<div class="tabs-content <%= "tabs-content--active" unless params[:tab].present? && params[:tab] != "highlights" %>" data-tab="highlights" aria-hidden="<%= params[:tab] != "highlights" %>">
<div class="tabs-content <%= "tabs-content--active" unless params[:tab].present? && params[:tab] != "highlights" %>" data-tab="highlights">
<% @blocks.each do |block| %>
<div class="mt-1/1 mb-1/1" data-block-id="<%= block.id %>">
<%= render "blocks/profile/#{ block.name }", block: block %>
Expand All @@ -34,11 +34,11 @@
</div>
<% end %>

<div class="tabs-content <%= "tabs-content--active" unless (params[:tab].blank? && @blocks.any?) || (params[:tab].present? && params[:tab] != "codes") %>" data-tab="codes" aria-hidden="<%= params[:tab] != "images" %>">
<div class="tabs-content <%= "tabs-content--active" unless (params[:tab].blank? && @blocks.any?) || (params[:tab].present? && params[:tab] != "codes") %>" data-tab="codes">
<%= render "blocks/profile/list" %>
</div>

<div class="tabs-content <%= "tabs-content--active" if params[:tab] == "collections" %>" data-tab="collections" aria-hidden="<%= params[:tab] != "collections" %>">
<div class="tabs-content <%= "tabs-content--active" if params[:tab] == "collections" %>" data-tab="collections">
<%= render "blocks/profile/user_collections" %>
</div>
</div>

0 comments on commit b993767

Please sign in to comment.