From 8d8d9eb4de300926ad080a340ad8af8d607a8cc4 Mon Sep 17 00:00:00 2001 From: dajiaohuang Date: Fri, 18 Sep 2026 03:53:16 +0800 Subject: [PATCH] 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. --- script.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index c6427f5..9578f06 100644 --- a/script.js +++ b/script.js @@ -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); }