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] Make screen readers start with packages list on Search Page. #9465

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions src/NuGetGallery/Scripts/gallery/page-list-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ $(function() {

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

const storage = window['localStorage'];
const focusResultsColumnKey = 'focus_results_column';

if (storage && storage.getItem(focusResultsColumnKey)) {
storage.removeItem(focusResultsColumnKey);
joelverhagen marked this conversation as resolved.
Show resolved Hide resolved
document.getElementById('results-column').focus({ preventScroll: true });
}

const searchForm = document.forms.search;
const allFrameworks = document.querySelectorAll('.framework');
const allTfms = document.querySelectorAll('.tfm');
Expand Down Expand Up @@ -69,6 +77,11 @@ $(function() {
function submitSearchForm() {
constructFilterParameter(searchForm.frameworks, allFrameworks);
constructFilterParameter(searchForm.tfms, allTfms);

if (storage) {
storage.setItem(focusResultsColumnKey, true);
}

searchForm.submit();
}

Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/Views/Shared/ListPackages.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
</div>
}
</div>
<div class="@(Model.IsAdvancedSearchFlightEnabled ? "col-md-9" : "col-md-12")" id="results-column">
<div class="@(Model.IsAdvancedSearchFlightEnabled ? "col-md-9" : "col-md-12")" id="results-column" tabindex="0">
<div class="row">
<div class="col-md-9">
<h1 tabindex="0">
Expand Down