Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[A11y] Correct role attribute for package lists #9303

Merged
merged 3 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Bootstrap/dist/css/bootstrap.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Bootstrap/less/list-group.less
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,8 @@ button.list-group-item {
margin-bottom: 0;
line-height: 1.3;
}

ul.list-packages {
list-style-type: none;
padding-left: 0;
}
6 changes: 3 additions & 3 deletions src/NuGetGallery/Views/Shared/ListPackages.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<section role="main" class="container main-container page-list-packages">
<div class="row clearfix no-margin">
<div class="col-md-10 no-padding">
<h1 role="alert">
<h1 role="heading">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is role="heading" necessary for h1 tags?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it wasn't necessary, the screen reader announces h1 tags as headings anyway. I removed the header role from this element. I also added tabindex=0 to this element so that screen readers can read the heading, which they were skipping previously.

@if (String.IsNullOrEmpty(Model.SearchTerm))
{
if (Model.TotalCount == 1)
Expand Down Expand Up @@ -151,7 +151,7 @@
</div>
}

<div class="list-packages" role="list">
<ul class="list-packages">
@{
var itemIndex = Model.PageIndex * Model.PageSize;
var eventName = Model.IsPreviewSearch ? "preview-search-selection" : "search-selection";
Expand All @@ -161,7 +161,7 @@
@Html.Partial("_ListPackage", package, new ViewDataDictionary { { "itemIndex", itemIndex }, { "eventName", eventName } })
itemIndex++;
}
</div>
</ul>

<div class="row">
<div class="col-xs-12 clearfix">
Expand Down
4 changes: 2 additions & 2 deletions src/NuGetGallery/Views/Shared/_ListPackage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
}

<article class="package" role="listitem">
<li class="package">
advay26 marked this conversation as resolved.
Show resolved Hide resolved

<div class="row">
<div class="col-sm-1 hidden-xs hidden-sm col-package-icon">
Expand Down Expand Up @@ -131,4 +131,4 @@
</div>
</div>
</div>
</article>
</li>
4 changes: 2 additions & 2 deletions src/NuGetGallery/Views/Users/Profiles.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@

<hr class="profile-title-divider" />

<div class="list-packages" role="list">
<ul class="list-packages">
@foreach (var package in Model.PagedPackages)
{
@Html.Partial("_ListPackage", package)
}
</div>
</ul>

@ViewHelpers.PreviousNextPager(Model.Pager)
</article>
Expand Down