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

[Redesign] Fix registration's link to the README #8699

Merged
merged 3 commits into from
Jul 23, 2021
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
16 changes: 13 additions & 3 deletions src/NuGetGallery/Scripts/gallery/page-display-package-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
var packageManagerStorageKey = 'preferred_package_manager';
var bodyStorageKey = 'preferred_body_tab';

// The V3 registration API links to the display package page's README using
// the 'show-readme-container' URL fragment.
var restorePreferredBodyTab = true;
if (window.location.hash === '#show-readme-container') {
$('#readme-body-tab').focus();
zhhyu marked this conversation as resolved.
Show resolved Hide resolved
restorePreferredBodyTab = false;
}

if (storage) {
// Restore preferred package manager selection from localStorage.
var preferredPackageManagerId = storage.getItem(packageManagerStorageKey);
Expand All @@ -64,9 +72,11 @@
}

// Restore preferred body tab selection from localStorage.
var preferredBodyTab = storage.getItem(bodyStorageKey);
if (preferredBodyTab) {
$('#' + preferredBodyTab).tab('show');
if (restorePreferredBodyTab) {
var preferredBodyTab = storage.getItem(bodyStorageKey);
if (preferredBodyTab) {
$('#' + preferredBodyTab).tab('show');
}
}

// Make sure we save the user's preferred body tab to localStorage.
Expand Down
21 changes: 16 additions & 5 deletions src/NuGetGallery/Views/Packages/DisplayPackageV2.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,25 @@
<ul class="nav nav-tabs" role="tablist">
@if (!Model.Deleted)
{
<li role="presentation" class="active"><a href="#readme-tab" aria-controls="ReadMe" role="tab" data-toggle="tab" id="readme-body-tab" class="body-tab">README</a></li>
<li role="presentation"><a href="#dependencies-tab" aria-controls="Dependencies" role="tab" data-toggle="tab" id="dependencies-body-tab" class="body-tab">Dependencies</a></li>
<li role="presentation" class="active" id="show-readme-container">
zhhyu marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not very sure. Do we need the id here?

Copy link
Contributor Author

@loic-sharma loic-sharma Jul 23, 2021

Choose a reason for hiding this comment

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

Yup, as the browser will move down the page to the element with the show-readme-container ID when I have the URL fragment #show-readme-container. (The .focus() in javascript does not do that, it simply highlights the element)

<a href="#readme-tab" aria-controls="readme-tab" role="tab" data-toggle="tab" id="readme-body-tab" class="body-tab">README</a>
zhhyu marked this conversation as resolved.
Show resolved Hide resolved
</li>
<li role="presentation">
<a href="#dependencies-tab" aria-controls="dependencies-tab" role="tab" data-toggle="tab" id="dependencies-body-tab" class="body-tab">Dependencies</a>
</li>
}
<li role="presentation"><a href="#usedby-tab" aria-controls="UsedBy" role="tab" data-toggle="tab" id="usedby-body-tab" class="body-tab">Used By</a></li>
<li role="presentation"><a href="#versions-tab" aria-controls="Versions" role="tab" data-toggle="tab" id="versions-body-tab" class="body-tab">Versions</a></li>
<li role="presentation">
<a href="#usedby-tab" aria-controls="usedby-tab" role="tab" data-toggle="tab" id="usedby-body-tab" class="body-tab">Used By</a>
</li>
<li role="presentation">
<a href="#versions-tab" aria-controls="versions-tab" role="tab" data-toggle="tab" id="versions-body-tab" class="body-tab">Versions</a>
</li>

@if (!String.IsNullOrWhiteSpace(Model.ReleaseNotes))
{
<li role="presentation"><a href="#releasenotes-tab" aria-controls="ReleaseNotes" role="tab" data-toggle="tab" id="release-body-tab" class="body-tab">Release Notes</a></li>
<li role="presentation">
<a href="#releasenotes-tab" aria-controls="releasenotes-tab" role="tab" data-toggle="tab" id="release-body-tab" class="body-tab">Release Notes</a>
</li>
}
</ul>
</div>
Expand Down