Tag filtering fix on mobile
This commit is contained in:
@@ -5,6 +5,7 @@ import { Button } from "./ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Badge } from "./ui/badge";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger } from "./ui/select";
|
||||
import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "./ui/command";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
|
||||
import { useTheme } from "./ThemeProvider";
|
||||
import { getThemeAdjustedColor } from "@/lib/colors";
|
||||
@@ -12,6 +13,8 @@ import { getThemeAdjustedColor } from "@/lib/colors";
|
||||
export const FilterBar: Component<{ mode?: 'tasks' | 'notes', class?: string, triggerClass?: string }> = (props) => {
|
||||
const { resolvedTheme } = useTheme();
|
||||
const [isOpen, setIsOpen] = createSignal(false);
|
||||
const [isTagOpen, setIsTagOpen] = createSignal(false);
|
||||
const [tagSearch, setTagSearch] = createSignal("");
|
||||
const [newTemplateName, setNewTemplateName] = createSignal("");
|
||||
const [isSaving, setIsSaving] = createSignal(false);
|
||||
|
||||
@@ -294,22 +297,53 @@ export const FilterBar: Component<{ mode?: 'tasks' | 'notes', class?: string, tr
|
||||
</Badge>
|
||||
)}
|
||||
</For>
|
||||
<Select
|
||||
value=""
|
||||
onChange={(val) => {
|
||||
if (val && !currentFilter().tags.some(t => t.name === val)) {
|
||||
currentSetFilter({ tags: [...currentFilter().tags, { name: val, excluded: false }] });
|
||||
}
|
||||
}}
|
||||
options={allTags()}
|
||||
placeholder="Add tag..."
|
||||
itemComponent={(props) => <SelectItem item={props.item}>{props.item.rawValue}</SelectItem>}
|
||||
>
|
||||
<SelectTrigger class="h-7 px-3 bg-muted/40 border-none shadow-none focus:ring-0 text-[0.625rem] font-bold uppercase tracking-wider rounded-lg hover:bg-muted/60 transition-colors">
|
||||
<Popover open={isTagOpen()} onOpenChange={setIsTagOpen}>
|
||||
<PopoverTrigger class="h-7 px-3 bg-muted/40 border-none shadow-none focus:ring-0 text-[0.625rem] font-bold uppercase tracking-wider rounded-lg hover:bg-muted/60 transition-colors">
|
||||
<span>+ Tag</span>
|
||||
</SelectTrigger>
|
||||
<SelectContent />
|
||||
</Select>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent class="w-[200px] p-0" align="start">
|
||||
<Command>
|
||||
<CommandInput
|
||||
placeholder="Search tags..."
|
||||
value={tagSearch()}
|
||||
onValueChange={setTagSearch}
|
||||
/>
|
||||
<CommandList>
|
||||
<Show when={allTags().filter(t => {
|
||||
if (t.startsWith('_')) return false;
|
||||
const search = tagSearch().toLowerCase();
|
||||
if (!search && (t.startsWith('@') || t.startsWith('#'))) return false;
|
||||
return t.toLowerCase().includes(search);
|
||||
}).length === 0}>
|
||||
<CommandEmpty>No tags found.</CommandEmpty>
|
||||
</Show>
|
||||
<CommandGroup>
|
||||
<For each={allTags().filter(t => {
|
||||
if (t.startsWith('_')) return false;
|
||||
const search = tagSearch().toLowerCase();
|
||||
if (!search && (t.startsWith('@') || t.startsWith('#'))) return false;
|
||||
return t.toLowerCase().includes(search);
|
||||
})}>
|
||||
{(tag) => (
|
||||
<CommandItem
|
||||
value={tag}
|
||||
onSelect={() => {
|
||||
if (!currentFilter().tags.some(t => t.name === tag)) {
|
||||
currentSetFilter({ tags: [...currentFilter().tags, { name: tag, excluded: false }] });
|
||||
}
|
||||
setIsTagOpen(false);
|
||||
setTagSearch("");
|
||||
}}
|
||||
>
|
||||
{tag}
|
||||
</CommandItem>
|
||||
)}
|
||||
</For>
|
||||
</CommandGroup>
|
||||
</CommandList>
|
||||
</Command>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user