From cddc2ff4790f49488c4b0fee7c72f23fdfe1a59d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Sep 2025 23:57:23 +0000 Subject: [PATCH 1/3] Initial plan From 2a38e2db70930b000fbf7821eb03900d0ae4b0a2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Sep 2025 00:12:08 +0000 Subject: [PATCH 2/3] Fix tab flicker on version change by preventing initial tab content visibility when localStorage preference differs from default Co-authored-by: skofman1 <16807822+skofman1@users.noreply.github.com> --- .../Scripts/gallery/page-display-package.js | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/NuGetGallery/Scripts/gallery/page-display-package.js b/src/NuGetGallery/Scripts/gallery/page-display-package.js index d774974ef9..3e208705b9 100644 --- a/src/NuGetGallery/Scripts/gallery/page-display-package.js +++ b/src/NuGetGallery/Scripts/gallery/page-display-package.js @@ -1,6 +1,20 @@ $(function () { 'use strict'; + // Prevent tab flicker by checking localStorage early and hiding content if needed + var storage = window['localStorage']; + var bodyStorageKey = 'preferred_body_tab'; + var shouldHideContentInitially = false; + + if (storage && !window.location.hash) { + var preferredBodyTab = storage.getItem(bodyStorageKey); + if (preferredBodyTab && preferredBodyTab !== 'readme-body-tab') { + shouldHideContentInitially = true; + // Temporarily hide the tab content to prevent flicker + $('.body-tab-content').css('visibility', 'hidden'); + } + } + // Configure the rename information container window.nuget.configureExpander("rename-content-container", "ChevronDown", null, "ChevronUp"); configureExpanderWithEnterKeydown($('#show-rename-content-container')); @@ -90,9 +104,7 @@ } // Restore previously selected package manager and body tab. - var storage = window['localStorage']; var packageManagerStorageKey = 'preferred_package_manager'; - var bodyStorageKey = 'preferred_body_tab'; var restorePreferredBodyTab = true; var windowHash = window.location.hash; @@ -107,6 +119,12 @@ $(windowHash).tab('show'); // don't restore body tab given the window hash restorePreferredBodyTab = false; + + // If we have a hash, we can safely show content now + if (shouldHideContentInitially) { + $('.body-tab-content').css('visibility', 'visible'); + shouldHideContentInitially = false; + } } if (storage) { @@ -125,6 +143,11 @@ } } + // Restore visibility if we hid content to prevent flicker + if (shouldHideContentInitially) { + $('.body-tab-content').css('visibility', 'visible'); + } + var usedByClamped = false; var usedByTab = $('#usedby-tab'); From 376434b64c4c3843c14182a8f354de55b4e0742e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Sep 2025 00:13:22 +0000 Subject: [PATCH 3/3] Improve tab flicker fix to dynamically detect active tab instead of hardcoding README tab check Co-authored-by: skofman1 <16807822+skofman1@users.noreply.github.com> --- src/NuGetGallery/Scripts/gallery/page-display-package.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NuGetGallery/Scripts/gallery/page-display-package.js b/src/NuGetGallery/Scripts/gallery/page-display-package.js index 3e208705b9..587cc2a9a2 100644 --- a/src/NuGetGallery/Scripts/gallery/page-display-package.js +++ b/src/NuGetGallery/Scripts/gallery/page-display-package.js @@ -8,7 +8,8 @@ if (storage && !window.location.hash) { var preferredBodyTab = storage.getItem(bodyStorageKey); - if (preferredBodyTab && preferredBodyTab !== 'readme-body-tab') { + // Check if there's a stored preference that differs from the server-rendered active tab + if (preferredBodyTab && $('.body-tabs .nav-tabs li.active a').attr('id') !== preferredBodyTab) { shouldHideContentInitially = true; // Temporarily hide the tab content to prevent flicker $('.body-tab-content').css('visibility', 'hidden');