Fix: read search query from both query param and form body

This commit is contained in:
2026-07-06 15:30:48 +02:00
parent e577d58dd9
commit aa1234d363
2 changed files with 7 additions and 4 deletions
@@ -79,14 +79,17 @@ public class ArtistController {
@DELETE
@Path("/{mbid}/from-search")
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public TemplateInstance removeArtistFromSearch(@PathParam("mbid") String mbid,
@QueryParam("q") @DefaultValue("") String q) {
@QueryParam("q") @DefaultValue("") String q,
@FormParam("q") @DefaultValue("") String qForm) {
artistService.removeArtist(mbid);
var query = q != null && !q.isBlank() ? q : qForm;
List<SearchResult> results;
if (q == null || q.isBlank()) {
if (query.isBlank()) {
results = List.of();
} else {
results = artistService.search(q);
results = artistService.search(query);
}
return searchResultsTemplate.data("artists", results);
}
@@ -22,7 +22,7 @@
{#if artist.alreadyTracked}
<button class="btn btn-warning btn-sm"
hx-delete="/api/artists/{artist.mbid}/from-search"
hx-vals='js:{{q: document.getElementById("search-input").value}}'
hx-include="#search-input"
hx-target="#search-results"
hx-swap="innerHTML">✓ Added</button>
{#else}