Skip to content

Commit bb59d0a

Browse files
committed
Add button to clear download filter
1 parent fd0593f commit bb59d0a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/tribler/ui/src/pages/Downloads/index.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { useInterval } from "@/hooks/useInterval";
2121
import { usePrevious } from "@/hooks/usePrevious";
2222
import { useResizeObserver } from "@/hooks/useResizeObserver";
2323
import { ContextMenu, ContextMenuTrigger } from "@/components/ui/context-menu";
24+
import { Button } from "@/components/ui/button";
25+
import { XIcon } from "lucide-react";
2426

2527

2628
export const filterAll = [1, 2, 3, 4, 5, 6, 7, 8, 9];
@@ -212,12 +214,24 @@ export default function Downloads({ statusFilter }: { statusFilter: number[] })
212214
selectedDownloads.filter((d) => d.status_code !== StatusCode.LOADING)} />
213215
</div>
214216
<div>
215-
<div className="flex items-center">
217+
<div className="relative w-full max-w-sm">
216218
<Input
219+
value={filters.find((filter) => filter.id == "name")?.value}
217220
placeholder={t('FilterByName')}
218221
onChange={(event) => setFilters([{ id: 'name', value: event.target.value }])}
219222
className="max-w-sm"
220223
/>
224+
{filters.find((filter) => filter.id == "name")?.value && <Button
225+
type="button"
226+
variant="ghost"
227+
size="icon"
228+
className="absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7 text-gray-500
229+
hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100"
230+
onClick={() => setFilters([{ id: 'name', value: "" }])}
231+
>
232+
<XIcon className="h-4 w-4" />
233+
<span className="sr-only">Clear</span>
234+
</Button>}
221235
</div>
222236
</div>
223237
</CardHeader>

0 commit comments

Comments
 (0)