Skip to content

Commit 1ad2907

Browse files
committed
fix: hiden sort filter when searching model
1 parent c3b043e commit 1ad2907

File tree

1 file changed

+47
-44
lines changed

1 file changed

+47
-44
lines changed

web-app/src/routes/hub/index.tsx

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,16 @@ function Hub() {
146146
}
147147
// Apply downloaded filter
148148
if (showOnlyDownloaded) {
149-
filtered = filtered?.map((model) => ({
150-
...model,
151-
quants: model.quants.filter((variant) =>
152-
llamaProvider?.models.some(
153-
(m: { id: string }) => m.id === variant.model_id
154-
)
155-
)
156-
})).filter((model) => model.quants.length > 0)
149+
filtered = filtered
150+
?.map((model) => ({
151+
...model,
152+
quants: model.quants.filter((variant) =>
153+
llamaProvider?.models.some(
154+
(m: { id: string }) => m.id === variant.model_id
155+
)
156+
),
157+
}))
158+
.filter((model) => model.quants.length > 0)
157159
}
158160
// Add HuggingFace repo at the beginning if available
159161
if (huggingFaceRepo) {
@@ -428,43 +430,44 @@ function Hub() {
428430
const isLastStep = currentStepIndex === steps.length - 1
429431

430432
const renderFilter = () => {
431-
return (
432-
<>
433-
<DropdownMenu>
434-
<DropdownMenuTrigger>
435-
<span className="flex cursor-pointer items-center gap-1 px-2 py-1 rounded-sm bg-main-view-fg/15 text-sm outline-none text-main-view-fg font-medium">
436-
{
437-
sortOptions.find((option) => option.value === sortSelected)
438-
?.name
439-
}
433+
if (searchValue.length === 0)
434+
return (
435+
<>
436+
<DropdownMenu>
437+
<DropdownMenuTrigger>
438+
<span className="flex cursor-pointer items-center gap-1 px-2 py-1 rounded-sm bg-main-view-fg/15 text-sm outline-none text-main-view-fg font-medium">
439+
{
440+
sortOptions.find((option) => option.value === sortSelected)
441+
?.name
442+
}
443+
</span>
444+
</DropdownMenuTrigger>
445+
<DropdownMenuContent side="bottom" align="end">
446+
{sortOptions.map((option) => (
447+
<DropdownMenuItem
448+
className={cn(
449+
'cursor-pointer my-0.5',
450+
sortSelected === option.value && 'bg-main-view-fg/5'
451+
)}
452+
key={option.value}
453+
onClick={() => setSortSelected(option.value)}
454+
>
455+
{option.name}
456+
</DropdownMenuItem>
457+
))}
458+
</DropdownMenuContent>
459+
</DropdownMenu>
460+
<div className="flex items-center gap-2">
461+
<Switch
462+
checked={showOnlyDownloaded}
463+
onCheckedChange={setShowOnlyDownloaded}
464+
/>
465+
<span className="text-xs text-main-view-fg/70 font-medium whitespace-nowrap">
466+
{t('hub:downloaded')}
440467
</span>
441-
</DropdownMenuTrigger>
442-
<DropdownMenuContent side="bottom" align="end">
443-
{sortOptions.map((option) => (
444-
<DropdownMenuItem
445-
className={cn(
446-
'cursor-pointer my-0.5',
447-
sortSelected === option.value && 'bg-main-view-fg/5'
448-
)}
449-
key={option.value}
450-
onClick={() => setSortSelected(option.value)}
451-
>
452-
{option.name}
453-
</DropdownMenuItem>
454-
))}
455-
</DropdownMenuContent>
456-
</DropdownMenu>
457-
<div className="flex items-center gap-2">
458-
<Switch
459-
checked={showOnlyDownloaded}
460-
onCheckedChange={setShowOnlyDownloaded}
461-
/>
462-
<span className="text-xs text-main-view-fg/70 font-medium whitespace-nowrap">
463-
{t('hub:downloaded')}
464-
</span>
465-
</div>
466-
</>
467-
)
468+
</div>
469+
</>
470+
)
468471
}
469472

470473
return (

0 commit comments

Comments
 (0)