fix(csb): custom-section book picker search never worked — two latent bugs
Fine-toothed functional verification of the delegation work exposed that the picker's book search has been dead since launch, for two independent reasons: - The builder fetched GET /api/books/search, a route no router has ever registered — every search 404'd (the CSP-dead onclick buttons on the results hid the failure). It now calls the unified JSON search the bookshelf uses (/api/media-items/search?q=&library_id=), maps its rows (id/title/author/cover_image_path) to the picker's BookInfo shape, and treats the endpoint's 404-with-results:[] as empty. - Even with results, the picker container shared id=search-results with the header search dropdown (header.templ renders it on every page); getElementById returns the first match in tree order, so results were written into the invisible topbar dropdown. The picker container is now cs-search-results (templ + all three TS references). Verified end-to-end at 390x844: select library -> search '1984' -> 3 results render -> click adds the selection chip -> chip x removes it. Zero console errors.
This commit is contained in:
1 parent
12aab156f6
commit
ef4de7896a
3 files changed
+38
-8
No files matched your search
@@ -136,7 +136,7 @@ templ CustomSectionBuilder(user User, libraries []LibraryData, errorMessage stri
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
id="search-results"
|
||||
id="cs-search-results"
|
||||
class="hidden mb-4 card p-3 max-h-60 overflow-y-auto space-y-2"
|
||||
style="background-color: var(--bg-primary);"
|
||||
></div>
|
||||
|
||||
Reference in new issue
Block a user