From 27848798726ed811f8ecb720178acb4dd26582e8 Mon Sep 17 00:00:00 2001 From: Benjamin Hardy Date: Thu, 1 Oct 2026 13:32:54 +0200 Subject: [PATCH] Added a clear button for the search bar --- frontend/src/components/Toolbar.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Toolbar.tsx b/frontend/src/components/Toolbar.tsx index 9cd0341..bb30846 100644 --- a/frontend/src/components/Toolbar.tsx +++ b/frontend/src/components/Toolbar.tsx @@ -1,3 +1,4 @@ +import { useRef } from 'react' import { useQuery } from '@tanstack/react-query' import { api } from '../api' import { useCaps } from '../lib/capabilities' @@ -37,6 +38,7 @@ export function Toolbar({ }: Props) { const caps = useCaps() const { data: facets } = useQuery({ queryKey: ['facets'], queryFn: api.facets }) + const searchRef = useRef(null) const set = (patch: Partial) => onChange({ ...filters, ...patch }) const active = filters.search || @@ -56,9 +58,24 @@ export function Toolbar({ set({ search: e.target.value })} + ref={searchRef} placeholder="Search artist, title, album…" - className="well w-72 rounded-full py-1.5 pl-9 pr-3 text-sm text-text outline-none placeholder:text-faint focus:ring-1 focus:ring-accent" + className="well w-72 rounded-full py-1.5 pl-9 pr-8 text-sm text-text outline-none placeholder:text-faint focus:ring-1 focus:ring-accent" /> + {filters.search && ( + + )}