fix(courts, glossary): honor ?q= URL param on init for search-palette deep links (t-paliad-046)

The global search palette emits /courts?q=... and /glossary?q=... but the
client bundles only wired the search input to live keystrokes — the URL
parameter was ignored on load. Clicking a court or glossary result in the
palette landed on the right page but showed all 41 courts / all glossary
terms instead of the expected single match.

Fix: in each page's initSearch(), read URLSearchParams.get('q') and prefill
the input value + module-level searchQuery before the data loads. The
existing render() call after fetch resolves already reads searchQuery.

Out of scope: /links has no search input today (palette also emits
/links?q=...). Flagged for a follow-up — adding a search input is a feature
addition, not a bug fix.
This commit is contained in:
m
2026-04-26 14:48:07 +02:00
parent 1b0de2f89c
commit 58692a4411
2 changed files with 14 additions and 0 deletions

View File

@@ -291,6 +291,13 @@ function initSearch() {
searchQuery = input.value;
render();
});
// Honor `?q=` from the global search-palette deep links. render() runs
// after loadCourts() resolves and reads the module-level searchQuery.
const q = new URLSearchParams(location.search).get("q");
if (q) {
input.value = q;
searchQuery = q;
}
}
// --- Feedback modal ---

View File

@@ -85,6 +85,13 @@ function initSearch() {
searchQuery = input.value;
render();
});
// Honor `?q=` from the global search-palette deep links. render() runs
// after loadTerms() resolves and reads the module-level searchQuery.
const q = new URLSearchParams(location.search).get("q");
if (q) {
input.value = q;
searchQuery = q;
}
}
// --- Category filters ---