diff --git a/website/static/main.js b/website/static/main.js index 919aefd4..93eac711 100644 --- a/website/static/main.js +++ b/website/static/main.js @@ -288,6 +288,7 @@ function sortRows() { const sortHeaders = document.querySelectorAll("th[data-sort]"); function updateSortIndicators() { + if (table) table.classList.toggle("sorted", activeSort.col !== "editorial"); sortHeaders.forEach(function (th) { th.classList.remove("sort-asc", "sort-desc"); if (th.dataset.sort === activeSort.col) { @@ -364,6 +365,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 () { diff --git a/website/static/style.css b/website/static/style.css index 4e067c06..12ff6cdf 100644 --- a/website/static/style.css +++ b/website/static/style.css @@ -868,6 +868,11 @@ kbd { text-underline-offset: 0.2em; } +/* main.js adds .sorted once a column sort flattens the groups */ +.table:not(.sorted) .repeats-heading { + display: none; +} + .group-count { font-family: var(--font-body); font-size: var(--text-sm); diff --git a/website/templates/category.html b/website/templates/category.html index 7528da00..e8d05860 100644 --- a/website/templates/category.html +++ b/website/templates/category.html @@ -76,6 +76,9 @@ {% endblock %} {% block content %} {% macro entry_rows(entry, index) %} + {# On section and subcategory pages the group heading already names the row's use case #} + {% set grouped_page = entry_groups and not group_categories %} + {% set section_path = "/categories/" ~ parent_category.slug ~ "/" if parent_category else current_path %}