diff --git a/src/lib/components/functional/FormatDropdown.svelte b/src/lib/components/functional/FormatDropdown.svelte index ed315d1..06af549 100644 --- a/src/lib/components/functional/FormatDropdown.svelte +++ b/src/lib/components/functional/FormatDropdown.svelte @@ -11,7 +11,6 @@ selected?: string; onselect?: (option: string) => void; disabled?: boolean; - settingsStyle?: boolean; }; let { @@ -19,7 +18,6 @@ selected = $bindable(""), onselect, disabled, - settingsStyle, }: Props = $props(); let open = $state(false); let hover = $state(false); @@ -60,7 +58,6 @@ categories[cat].canConvertTo?.includes(currentCategory || ""), ); }); - const filteredData = $derived.by(() => { if (!searchQuery) { return { @@ -71,13 +68,6 @@ }; } - // filter formats across all available categories - const allFormats = availableCategories.flatMap((cat) => - categories[cat].formats.filter((format) => - format.toLowerCase().includes(searchQuery.toLowerCase()), - ), - ); - // filter categories that have matching formats const matchingCategories = availableCategories.filter((cat) => categories[cat].formats.some((format) => @@ -85,9 +75,19 @@ ), ); + // only show formats from the current category that match the search + const filteredFormats = + currentCategory && categories[currentCategory] + ? categories[currentCategory].formats.filter((format) => + format + .toLowerCase() + .includes(searchQuery.toLowerCase()), + ) + : []; + return { categories: matchingCategories, - formats: allFormats, + formats: filteredFormats, }; }); @@ -98,11 +98,8 @@ }; const selectCategory = (category: string) => { - if (categories[category]) { - currentCategory = category; - // clear search when switching categories - searchQuery = ""; - } + if (!categories[category]) return; + currentCategory = category; }; const handleSearch = (event: Event) => { @@ -137,21 +134,13 @@
+ {#if open}