fix: restore hidden group headings when navigating to a jump link

After sorting by a column, or while a search hid a group, category page group headings stayed hidden, so the header's jump links (and any use-case heading link) pointed at a hidden element and did nothing.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-09-27 02:04:41 +08:00
co-authored by Claude
parent f68450769b
commit ef00fe3adb
+18
View File
@@ -364,6 +364,24 @@ sortHeaders.forEach(function (th) {
});
});
// Group headings are hidden while sorted flat or filtered out by search, so a link to one must restore them first
document.addEventListener("click", function (e) {
const link = e.target.closest('a[href*="#"]');
if (!link || link.pathname !== location.pathname) return;
const heading = document.getElementById(decodeURIComponent(link.hash.slice(1)));
const groupRow = heading ? heading.closest(".group-row") : null;
if (!groupRow) return;
if (activeSort.col !== "editorial") {
activeSort = defaultSort;
sortRows();
updateSortIndicators();
}
if (groupRow.hidden && searchInput) {
searchInput.value = "";
applyFilters();
}
});
if (searchInput) {
let searchTimer;
searchInput.addEventListener("input", function () {