fix: restore the section view when the search box is cleared

The nav link's textContent includes the whitespace around the chevron
icon, so it never matched the trimmed section keys in
window.parsedResources. displaySection() cleared the container and then
threw, leaving the page with only a section heading and no resources.

Trim the value so clearing the search restores the active section.
This commit is contained in:
dajiaohuang
2026-09-18 03:53:16 +08:00
parent ee05296cf0
commit 8d8d9eb4de
+3 -1
View File
@@ -496,7 +496,9 @@ searchInput.addEventListener('input', (e) => {
if (!searchTerm) {
// If search is empty, restore current category view
const currentCategory = document.querySelector('.nav-links a.active')?.textContent;
// (the nav link's textContent carries the icon markup's whitespace,
// so it must be trimmed to match the keys in window.parsedResources)
const currentCategory = document.querySelector('.nav-links a.active')?.textContent.trim();
if (currentCategory) {
displaySection(currentCategory, window.parsedResources);
}