Skip to content

Commit 13a10ba

Browse files
author
Daniel Jacinto
authored
[A11y] Make screen readers start with packages list on Search Page. (#9465)
* focus when Search buttons are clicked. * nit.
1 parent bbbea72 commit 13a10ba

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/NuGetGallery/Scripts/gallery/page-list-packages.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ $(function() {
33

44
$(".reserved-indicator").each(window.nuget.setPopovers);
55

6+
const storage = window['localStorage'];
7+
const focusResultsColumnKey = 'focus_results_column';
8+
9+
if (storage && storage.getItem(focusResultsColumnKey)) {
10+
storage.removeItem(focusResultsColumnKey);
11+
document.getElementById('results-column').focus({ preventScroll: true });
12+
}
13+
614
const searchForm = document.forms.search;
715
const allFrameworks = document.querySelectorAll('.framework');
816
const allTfms = document.querySelectorAll('.tfm');
@@ -69,6 +77,11 @@ $(function() {
6977
function submitSearchForm() {
7078
constructFilterParameter(searchForm.frameworks, allFrameworks);
7179
constructFilterParameter(searchForm.tfms, allTfms);
80+
81+
if (storage) {
82+
storage.setItem(focusResultsColumnKey, true);
83+
}
84+
7285
searchForm.submit();
7386
}
7487

src/NuGetGallery/Views/Shared/ListPackages.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
</div>
136136
}
137137
</div>
138-
<div class="@(Model.IsAdvancedSearchFlightEnabled ? "col-md-9" : "col-md-12")" id="results-column">
138+
<div class="@(Model.IsAdvancedSearchFlightEnabled ? "col-md-9" : "col-md-12")" id="results-column" tabindex="0">
139139
<div class="row">
140140
<div class="col-md-9">
141141
<h1 tabindex="0">

0 commit comments

Comments
 (0)